perseus

package module
v0.0.0-...-eb540b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 2 Imported by: 1

README

perseus

Go lang utils

Supported Features

Type

  • Number

Slice

  • Shift
  • Prepend
  • Remove
  • Cut
  • Insert
  • InsertVector
  • Pop
  • Extend
  • Sum

Document

Reference

Documentation

Overview

Package perseus is golang util operation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cut

func Cut[K any, V constraints.Integer](slice []K, i, j V) []K

Cut Delete from i to j from the slice

func Extend

func Extend[T any](A, B []T) []T

Extend connect slices together

func Insert

func Insert[K any, V constraints.Integer](slice []K, element K, position V) []K

Insert Insert element to specified position

func InsertVector

func InsertVector[K any, V constraints.Integer](origin, insert []K, position V) []K

InsertVector Insert slice to specified position

func Pop

func Pop[T any](slice []T) (T, []T)

Pop returns the last element of slice and other element's slice.

func Prepend

func Prepend[T any](sep T, i []T) []T

Prepend add an element to the beginning of a slice.

func Remove

func Remove[K any, V constraints.Integer](slice []K, sep V) []K

Remove Remove specified element from slice

func Repeat

func Repeat[T any](count int, v ...T) []T

func Shift

func Shift[T any](slice []T) (T, []T)

Shift returns the first element of slice and other element's slice.

func Sum

func Sum[T Number](values []T) T

func WithIndex

func WithIndex[K comparable, V any](m map[K]V) iter.Seq[KeyValueIndex[K, V]]

Types

type KeyValueIndex

type KeyValueIndex[K comparable, V any] struct {
	Index int
	Key   K
	Value V
}

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL