Documentation
¶
Index ¶
- func Every[V comparable, E any](l List[V], fn func(V) E) []E
- type List
- func Between[V comparable](min, max, chunk int, f func(start, count int) V) List[V]
- func Each[V, E comparable](l List[V], fn func(V) E) List[E]
- func Fill[V comparable](symbol V, count int) List[V]
- func From[V comparable](values []V) List[V]
- func FromString[V comparable](s string, separator string, mapper func(string) (V, bool)) List[V]
- func L[V comparable](values []V) List[V]
- func Range[V constraints.Integer](min, max V) List[V]
- func Sequence(symbol string, count int, start int) List[string]
- func Var[V comparable](values ...V) List[V]
- func (l List[V]) Add(v V) List[V]
- func (l List[V]) Chunk(size int) []List[V]
- func (l List[V]) Contains(v V) bool
- func (l List[V]) Delete(index uint) List[V]
- func (l List[V]) Each(mapper func(V) V) List[V]
- func (l List[V]) Empty() bool
- func (l List[V]) Filter(filter func(V) bool) List[V]
- func (l List[V]) First() V
- func (l List[V]) Interface() []interface{}
- func (l List[V]) Join(lists ...List[V]) List[V]
- func (l List[V]) JoinToString(separator string) string
- func (l List[V]) Last() V
- func (l List[V]) Len() int
- func (l List[V]) Nth(nth int) List[V]
- func (l List[V]) Random() V
- func (l List[V]) Reverse() List[V]
- func (l List[V]) Shuffle() List[V]
- func (l List[V]) Unique() List[V]
- func (l List[V]) Values() []V
- func (l List[V]) Zip(other List[V]) ([]List[V], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Every ¶ added in v0.5.0
func Every[V comparable, E any](l List[V], fn func(V) E) []E
Every apply the given func to each element of List[V] and return the new slice of E.
Types ¶
type List ¶
type List[V comparable] struct { // contains filtered or unexported fields }
List represents go slice of generic values as concurrency safe List[V].
func Between ¶ added in v0.6.0
func Between[V comparable](min, max, chunk int, f func(start, count int) V) List[V]
func Each ¶
func Each[V, E comparable](l List[V], fn func(V) E) List[E]
Each apply the given func to each element of List[V] and return the new List[E].
func Fill ¶ added in v0.2.1
func Fill[V comparable](symbol V, count int) List[V]
Fill create the List[V] from given V by the specified count.
func From ¶
func From[V comparable](values []V) List[V]
From creates the List[V] from the given slice.
func FromString ¶
FromString split the string by separator, apply the mapper for each value and output the List[V].
func Range ¶
func Range[V constraints.Integer](min, max V) List[V]
Range creates the list of given range constrained by Integer.
func Sequence ¶ added in v0.2.1
Sequence generate the List[string] of the given symbol concatenated with index. Useful for SQL query generation. In example: golist.Sequence("$", 3, 1).Values() [$1, $2, $3]
func (List[V]) Interface ¶ added in v0.3.1
func (l List[V]) Interface() []interface{}
Interface return List[V] as slice of interfaces.
func (List[V]) JoinToString ¶ added in v0.2.1
JoinToString joins the list elements if V is type of string. Otherwise, skip the value.