import "github.com/sudhirj/slicy"
func All[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) boolAll returns true if the given predicate returns true for every element of the
given slice.
func Any[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) boolAny return true if the given predicate returns true for any element of the
given slice.
func Chunk[S ~[]T, T any](slice S, chunkSize int) []SChunk splits the given slice into smaller slices, each the length of
chunkSize. If the slice cannot be split evenly, the last chunk will have the
remaining elements.
func Concat[S ~[]T, T any](slices ...S) SConcat combines all the elements from all the given slices into a single slice.
func CountBy[S ~[]T, T any, U comparable](slice S, iteratee func(T) U) map[U]intCountBy creates a map composed of keys generated from the results of running
each element of the slice through iteratee. The corresponding value of each
key is the number of times the key was returned by iteratee.
func Difference[S ~[]T, T comparable](slice S, others ...S) SDifference returns a list of items present in slice that are not present in
any of the others slices. The comparison is performed with ==.
func DifferenceBy[S ~[]T, T any, U comparable](slice S, iteratee func(T) U, others ...S) SDifferenceBy returns a list of items present in slice that are not present
in any of the others slices, with the comparison made by passing items into
the iteratee function and checking == on the result. This allows changing
the way the item is viewed for comparison.
func DifferenceWith[S ~[]T, T any](slice S, comparator func(T, T) bool, others ...S) SDifferenceWith returns a slice of items present in slice that are not
present in any of the others slices, with the comparison made using the given
comparator.
func Drop[S ~[]T, T any](slice S, n int) SDrop returns a new slice with n elements dropped from the beginning.
func DropRight[S ~[]T, T any](slice S, n int) SDropRight returns a new slice with n elements dropped from the end.
func DropRightWhile[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) SDropRightWhile creates a new slice excluding elements dropped from the end.
Elements are dropped until predicate returns false.
func DropWhile[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) SDropWhile creates a new slice excluding elements dropped from the beginning.
Elements are dropped until predicate returns false.
func Each[S ~[]T, T any](slice S, iteratee func(value T, index int, slice S))Each invokes the given iteratee for every element in the slice, from left to
right.
func EachRight[S ~[]T, T any](slice S, iteratee func(value T, index int, slice S))EachRight invokes the given iteratee for every element in the slice, from
right to left.
func Every[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) boolEvery returns true if the given predicate returns true for every element of
the given slice.
func Fill[S ~[]T, T any](slice S, value T, start int, end int)Fill fills elements of slice with value from start up to, but not
including end.
func Filter[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) SFilter iterates over the elements of slice, returning a slice of all elements
that the predicate returns true for.
func Find[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) (result T)Find iterates over the elements of slice, returning the first element that
predicate returns true for.
func FindIndex[S ~[]T, T any](slice S, predicate func(T) bool) intFindIndex returns the index of the first element for which the predicate
returns true.
func FindLastIndex[S ~[]T, T any](slice S, predicate func(T) bool) intFindLastIndex returns the index of the last element of which the predicate
returns true.
func FlatMap[S ~[]T, T any, U any](slice S, iteratee func(value T, index int, slice S) []U) []UFlatMap creates a flattened slice of values by running each element in slice
through iteratee and flattening the mapped results.
func GroupBy[S ~[]T, T any, U comparable](slice S, iteratee func(T) U) map[U]SGroupBy creates a map composed of keys generated from the results of running
each element of slice through iteratee. The order of the grouped values is
determined by the order that they occur in slice. The corresponding value of
each key is a slice of elements responsible for generating the key.
func Includes[S ~[]T, T comparable](slice S, value T) boolIncludes checks if value is in slice. Equality is checked with ==.
func IndexOf[S ~[]T, T comparable](slice S, value T) intIndexOf returns the index at which the first occurrence of value is found in
slice. Returns -1 if not found.
func Intersection[S ~[]T, T comparable](slices ...S) SIntersection returns a slice of unique values that are included in all given slices. The order of the result values are determined by the first slice.
func IntersectionBy[S ~[]T, T any, U comparable](iteratee func(T) U, others ...S) SIntersectionBy returns a slice of unique values that are included in all given
slices, with comparison happening on the result of the iteratee function. The
order of the result values are determined by the first slice.
func IntersectionWith[S ~[]T, T any](comparator func(T, T) bool, slices ...S) SIntersectionWith returns a slice of unique values that are included in all given
slice, with comparison happening inside the given comparator. The order of the
result values are determined by the first slice.
func Join[S ~[]T, T any](slice S, separator string) stringJoin concatenates all the elements of the slice into a string separated by
separator. fmt.Sprint is used for to get the string representation of the
given value, so mixed types are possible with []any.
func KeyBy[S ~[]T, T any, U comparable](slice S, iteratee func(T) U) map[U]TKeyBy creates a map composed of keys generated from the results of running each
element of slice through iteratee. The corresponding value of each key is
the last element responsible for generating the key.
func LastIndexOf[S ~[]T, T comparable](slice S, value T) intLastIndexOf returns the index at which the last occurrence of value is found
in slice. Returns -1 if not found.
func Map[S ~[]T, T any, U any](slice S, iteratee func(T) U) []UMap creates a slice of values by running each element in slice through
iteratee.
func Nth[S ~[]T, T any](slice S, n int) TNth gets the element at index n of the slice. If n is negative, the nth
element from the end is returned.
func Partition[S ~[]T, T any](slice S, predicate func(T) bool) (truths S, falsehoods S)Partition creates two slices, the first of which contains elements that
predicate returns true for, with the second containing elements for which
predicate returns false.
func Pull[S ~[]T, T comparable](slice S, values ...T) SPull returns a new slice without all the given values.
func PullAll[S ~[]T, T comparable](slice S, values []T) SPullAll returns a new slice without the items in values.
func PullAllBy[S ~[]T, T any, U comparable](slice S, values []T, iteratee func(T) U) SPullAllBy returns a new slice without the items in values, with the comparison
made by passing both values through the iteratee function.
func PullAllWith[S ~[]T, T any](slice S, values []T, comparator func(T, T) bool) SPullAllWith returns a new slice without the items in values, with the
comparison made using the given comparator.
func PullAt[S ~[]T, T comparable](slice S, indexes ...int) SPullAt returns a new slice without the items at the given indexes.
func Reduce[S ~[]T, T any, U any](slice S, iteratee func(acc U, value T, index int, slice S) U, accumulator U) UReduce reduces slice to a value which is the accumulated result of running
each element in slice through iteratee, where each successive invocation is
supplied the return value of the previous one. accumulator is used as the
initial value.
func ReduceRight[S ~[]T, T any, U any](slice S, iteratee func(acc U, value T, index int, slice S) U, accumulator U) UReduceRight reduces slice to a value which is the accumulated result of
running each element in slice, from right to left, through iteratee, where
each successive invocation is supplied the return value of the previous one.
accumulator is used as the initial value.
func Reject[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) SReject iterates over the elements of slice, returning a new slice of the
elements for which predicate returns false.
func Remove[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) SRemove returns a new slice without the elements for which the predicate
returns true.
func Reverse[S ~[]T, T any](slice S) SReverse return the reverse of slice: with the first element last, the second
element second-to-last, and so on.
func Some[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) boolSome return true if the given predicate returns true for any element of the
given slice.
func SortedIndex[S ~[]T, T constraints.Ordered](slice S, value T) intSortedIndex uses a binary search to determine the lowest index at which value
should be inserted into slice in order to maintain its sort order.
func SortedIndexBy[S ~[]T, T any, U constraints.Ordered](slice S, value T, iteratee func(T) U) intSortedIndexBy uses a binary search to determine the lowest index at which
value should be inserted into slice in order to maintain its sort order,
with the iteratee function used to compute sort ranking.
func SortedIndexOf[S ~[]T, T constraints.Ordered](slice S, value T) intSortedIndexOf performs a binary search on a sorted slice to find the given
value. Returns -1 if not found.
func SortedLastIndex[S ~[]T, T constraints.Ordered](slice S, value T) intSortedLastIndex returns the highest index at which value should be inserted
into the sorted slice to maintain its sort order.
func SortedLastIndexBy[S ~[]T, T any, U constraints.Ordered](slice S, value T, iteratee func(T) U) intSortedLastIndexBy returns the highest index at which value should be inserted
into the sorted slice to maintain its sort order, with comparisons made on the
result of passing all values through iteratee.
func SortedLastIndexOf[S ~[]T, T constraints.Ordered](slice S, value T) intSortedLastIndexOf returns the highest index at which the value is present in
the sorted slice.
func Take[S ~[]T, T any](slice S, n int) STake returns a new slice with n elements taken from the beginning.
func TakeRight[S ~[]T, T any](slice S, n int) STakeRight returns a new slice with n elements taken from the end.
func TakeRightWhile[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) STakeRightWhile creates a slice of elements taken from the end of slice.
Elements are taken until the predicate returns false.
func TakeWhile[S ~[]T, T any](slice S, predicate func(value T, index int, slice S) bool) STakeWhile creates a slice of elements taken from the beginning of slice.
Elements are taken until the predicate returns false.
func Union[S ~[]T, T comparable](slices ...S) SUnion creates a new slice, in order, of unique values of all the given slices.
Uses == for equality checks.
func UnionBy[S ~[]T, T any, U comparable](iteratee func(T) U, slices ...S) SUnionBy creates a new slice, in order, of unique values of all the given slices.
Uses the result of the given iteratee to check equality.
func UnionWith[S ~[]T, T any](comparator func(T, T) bool, sliceList ...S) SUnionWith creates a new slice, in order, of unique values of all the given
slices. Uses the given comparator to check equality between elements.
func Uniq[S ~[]T, T comparable](slice S) SUniq returns a new slice, in order, with no duplicates, with only the first
occurrence of each element kept. Comparison is performed with ==.
func UniqBy[S ~[]T, T any, U comparable](iteratee func(T) U, slice S) SUniqBy returns a new slice, in order, with no duplicates, with only the first
occurrence of each element kept. Comparison is performed with == on the result
of passing each element through the given iteratee.
func UniqWith[S ~[]T, T any](comparator func(T, T) bool, slice S) SUniqWith returns a new slice, in order, with no duplicates, with only the first
occurrence of each element kept. Comparison is performed using the given
comparator.
func Without[S ~[]T, T comparable](slice S, values ...T) SWithout returns a new slice without the given elements. Uses == for equality
checks.
func Xor[S ~[]T, T comparable](slices ...S) SXor returns a new slice of unique values that is the symmetric difference (elements which are any of the sets but not in their intersection) of the given slices. The order of result values is determined by the order they occur in the slices.
func XorBy[S ~[]T, T any, U comparable](iteratee func(T) U, slices ...S) SXorBy returns a new slice of unique values that is the symmetric difference
(elements which are any of the sets but not in their intersection) of the given
slices. The order of result values is determined by the order they occur in the
slices. Equality is determined by passing elements through the given iteratee.
func XorWith[S ~[]T, T any](comparator func(T, T) bool, sliceList ...S) SXorWith returns a new slice of unique values that is the symmetric difference
(elements which are any of the sets but not in their intersection) of the given
slices. The order of result values is determined by the order they occur in the
slices. Equality is determined by passing elements to the given comparator.