slice

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 7 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append[A any](xs []A, ys []A) []A

Append is from (++):

https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:-43--43-

func Break

func Break[A any](pred F1[A, bool], xs []A) *Pair[[]A, []A]

Break is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:break

func CartesianProduct added in v0.2.0

func CartesianProduct[A, B any](xs []A, ys []B) []*Pair[A, B]

func CartesianProductWith added in v0.2.0

func CartesianProductWith[A, B, C any](f func(A, B) C, xs []A, ys []B) []C

func ComparatorToLess added in v0.2.0

func ComparatorToLess[A any](comparator Comparator[A]) func(A, A) bool

ComparatorToLess was useful for working with older versions of the golang.org/x/exp/slices

package, whose sort functions used a different function type for comparison than they
currently do.  This function probably isn't useful anymore.

func CompareBy

func CompareBy[A any](comparisons ...Comparator[A]) Comparator[A]

func CompareBys

func CompareBys[A any](comparisons []Comparator[A]) Comparator[A]

func CompareIndex added in v0.2.9

func CompareIndex[A constraints.Ordered](i int) Comparator[[]A]

func CompareIndexBy added in v0.2.9

func CompareIndexBy[A any](i int, compare Comparator[A]) Comparator[[]A]

CompareIndexBy compares a single index

func CompareIndexOrd added in v0.2.9

func CompareIndexOrd[A Ord[A]](i int) Comparator[[]A]

func ComparePairwise added in v0.2.9

func ComparePairwise[A constraints.Ordered]() Comparator[[]A]

func ComparePairwiseBy added in v0.2.9

func ComparePairwiseBy[A any](compare Comparator[A]) Comparator[[]A]

ComparePairwiseBy should work as in Haskell. Examples from Haskell:

Prelude> [1,2,3] < [3,4,5]
True
Prelude> [1,2,3] < [3,4]
True
Prelude> [1,2,3] < []
False

func ComparePairwiseOrd added in v0.2.9

func ComparePairwiseOrd[A Ord[A]]() Comparator[[]A]

func ConcatMap

func ConcatMap[A any, B any](f F1[A, []B], xs []A) []B

ConcatMap is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:concatMap

func Cons

func Cons[A any](a A, xs []A) []A

Cons prepends an element to a slice. This implementation may be inefficient.

func DropWhile

func DropWhile[A any](pred F1[A, bool], xs []A) []A

DropWhile is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:dropWhile

func EqualBy

func EqualBy[A any](equals ...Equaler[A]) Equaler[A]

func EqualBys

func EqualBys[A any](equals []Equaler[A]) Equaler[A]

func EqualIndex added in v0.2.9

func EqualIndex[A comparable](i int) Equaler[[]A]

func EqualIndexBy added in v0.2.9

func EqualIndexBy[A any](i int, equal Equaler[A]) Equaler[[]A]

EqualIndexBy looks at a single index

func EqualIndexEq added in v0.2.9

func EqualIndexEq[A Eq[A]](i int) Equaler[[]A]

func EqualPairwise added in v0.2.9

func EqualPairwise[A comparable]() Equaler[[]A]

func EqualPairwiseBy added in v0.2.9

func EqualPairwiseBy[A any](equal Equaler[A]) Equaler[[]A]

func EqualPairwiseEq added in v0.2.9

func EqualPairwiseEq[A Eq[A]]() Equaler[[]A]

func Filter

func Filter[A any](f F1[A, bool], xs []A) []A

Filter is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:filter

func Foldl

func Foldl[A, B any](combine F2[B, A, B], base B, xs []A) B

Foldl is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:foldl

foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn

func Foldr

func Foldr[A, B any](combine F2[A, B, B], base B, xs []A) B

Foldr is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:foldr

foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)

func Group

func Group[A comparable](xs []A) map[A][]A

func GroupConsecutive

func GroupConsecutive[A Eq[A]](xs []A) [][]A

GroupConsecutive is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:group

func GroupConsecutiveBy

func GroupConsecutiveBy[A any](g F2[A, A, bool], xs []A) [][]A

GroupConsecutiveBy is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:groupBy

func GroupOn

func GroupOn[A any, B comparable](projection func(A) B, xs []A) map[B][]A

func Index

func Index[T comparable](s []T, e T) int

func IndexBy

func IndexBy[T any](equal Equaler[T], s []T, e T) int

func IndexEq

func IndexEq[T Eq[T]](s []T, e T) int

func Insert

func Insert[A Ord[A]](a A, xs []A) []A

Insert is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:insert

func Intercalate

func Intercalate[A any](sep []A, xss [][]A) []A

Intercalate is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:intercalate

func Intersperse

func Intersperse[A any](sep A, xs []A) []A

Intersperse is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:intersperse

func IsPrefixOf added in v0.2.0

func IsPrefixOf[A comparable](xs []A, ys []A) bool

func IsPrefixOfBy added in v0.2.0

func IsPrefixOfBy[A any](equal Equaler[A], xs []A, ys []A) bool

func IsPrefixOfEq added in v0.2.0

func IsPrefixOfEq[A Eq[A]](xs []A, ys []A) bool

func Iterate

func Iterate[A any](count int, f F1[A, A], start A) []A

Iterate is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:iterate

it uses a count to avoid an infinite slice

func Iterator added in v0.2.1

func Iterator[A any](xs []A) iterable.Iterator[A]

func Map

func Map[A, B any](f F1[A, B], xs []A) []B

Map is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:map

func MapAccumL

func MapAccumL[A, B, S any](accum F2[S, A, *Pair[S, B]], s S, xs []A) *Pair[S, []B]

MapAccumL is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:mapAccumL

forall t s a b. Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)

func MapAccumR

func MapAccumR[A, B, S any](accum F2[S, A, *Pair[S, B]], s S, xs []A) *Pair[S, []B]

MapAccumR is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:mapAccumR

forall t s a b. Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)

func Maximum

func Maximum[A Ord[A]](xs []A) *maybe.Maybe[A]

Maximum is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:maximum

since Haskell's maximum blows up on empty lists, this has been modified for safety

func MaximumBy

func MaximumBy[A any](f Comparator[A], xs []A) *maybe.Maybe[A]

MaximumBy is from https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:maximumBy

func Minimum

func Minimum[A Ord[A]](xs []A) *maybe.Maybe[A]

Minimum is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:minimum

since Haskell's minimum blows up on empty lists, this has been modified for safety

func MinimumBy

func MinimumBy[A any](f Comparator[A], xs []A) *maybe.Maybe[A]

MinimumBy is from https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:minimumBy

func Partition

func Partition[A any](predicate F1[A, bool], xs []A) *Pair[[]A, []A]

Partition is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:partition

func Range

func Range[A builtin.Number](start A, stop A, step A) []A

func Scanl

func Scanl[A, B any](combine F2[B, A, B], base B, xs []A) []B

Scanl is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:scanl

func Scanl1

func Scanl1[A any](combine F2[A, A, A], xs []A) []A

Scanl1 is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:scanl1

func Scanr

func Scanr[A, B any](combine F2[A, B, B], base B, xs []A) []B

Scanr is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:scanr

func Scanr1

func Scanr1[A any](combine F2[A, A, A], xs []A) []A

Scanr1 is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:scanr1

func SliceEq

func SliceEq[A Eq[A]](a []A) *EqBoxBy[[]A]

func SliceOrd

func SliceOrd[A Ord[A]](a []A) *OrdBoxBy[[]A]

func Sort

func Sort[A constraints.Ordered](xs []A) []A

Sort is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:sort

It orders elements by their natural Ord instance.

func SortBy

func SortBy[A any](compare Comparator[A], xs []A) []A

SortBy is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:sortBy

It allows sorting based on a custom comparison operator;
therefore it does not require input elements to have an Ord instance.

func SortOn

func SortOn[A any, B constraints.Ordered](projection F1[A, B], xs []A) []A

SortOn is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:sortOn

It uses the decorate/sort/undecorate pattern.
It allows a projection of each element to be used to determine the order.
The projection must be Ordered.

func SortOnBy

func SortOnBy[A any, B any](projection F1[A, B], compare Comparator[B], xs []A) []A

SortOnBy combines the functionality of `SortOn` and `SortBy`,

thereby separating projection and comparison functions

func SortOnOrd

func SortOnOrd[A any, B Ord[B]](projection F1[A, B], xs []A) []A

func SortOrd

func SortOrd[A Ord[A]](xs []A) []A

func Span

func Span[A any](pred F1[A, bool], xs []A) *Pair[[]A, []A]

Span is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:span

func SplitAt

func SplitAt[A any](count int, xs []A) *Pair[[]A, []A]

SplitAt is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:splitAt

func TakeWhile

func TakeWhile[A any](pred F1[A, bool], xs []A) []A

TakeWhile is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:takeWhile

func Uncons

func Uncons[A any](xs []A) *maybe.Maybe[*Pair[A, []A]]

Uncons is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:uncons

func Unfoldr

func Unfoldr[A, B any](f F1[B, *maybe.Maybe[*Pair[A, B]]], b B) []A

Unfoldr is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:unfoldr

func Unzip

func Unzip[A, B any](xs []*Pair[A, B]) *Pair[[]A, []B]

Unzip is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:unzip

func Zip

func Zip[A, B any](xs []A, ys []B) []*Pair[A, B]

Zip is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:zip

func ZipWith

func ZipWith[A, B, C any](f F2[A, B, C], xs []A, ys []B) []C

ZipWith is from: https://hackage.haskell.org/package/base-4.16.2.0/docs/Data-List.html#v:zipWith

Types

type Slice added in v0.2.1

type Slice[A any] []A

func (Slice[A]) Iterator added in v0.2.1

func (s Slice[A]) Iterator() iterable.Iterator[A]

Jump to

Keyboard shortcuts

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