slices

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 4 Imported by: 0

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 CompareBy

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

func CompareBys

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

func ComparePair

func ComparePair[A Ord[A], B Ord[B]](p1 *Pair[A, B], p2 *Pair[A, B]) Ordering

func CompareSlice

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

func CompareSliceHelper

func CompareSliceHelper[A any](compare Comparator[A], xs []A, ys []A) Ordering

CompareSliceHelper 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 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](comparisons ...Equaler[A]) Equaler[A]

func EqualBys

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

func EqualPair

func EqualPair[A Eq[A], B Eq[B]](p1 *Pair[A, B], p2 *Pair[A, B]) bool

func EqualSlice

func EqualSlice[A any](compare F2[A, A, bool]) F2[[]A, []A, bool]

func EqualSliceHelper

func EqualSliceHelper[A any](compare F2[A, A, bool], xs []A, ys []A) bool

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 Find

func Find[A any](pred F1[A, bool], xs []A) *pkg.Maybe[A]

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

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 Eq[A]](xs []A) [][]A

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

func GroupBy

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

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

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 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 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) *pkg.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) *pkg.Maybe[A]

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

func Merge

func Merge[A any](xs []A, ys []A, compare Comparator[A]) []A

Merge ...

func MergeSortWithComparator

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

MergeSortWithComparator needs to be rewritten iteratively TODO

func Minimum

func Minimum[A Ord[A]](xs []A) *pkg.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) *pkg.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 builtins.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 Sort

func Sort[A Ord[A]](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 Ord[B]](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 have an Ord instance.

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 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) *pkg.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, *pkg.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 SliceEq

type SliceEq[A Eq[A]] []A

func (SliceEq[A]) Equal

func (xs SliceEq[A]) Equal(ys SliceEq[A]) bool

type SliceOrd

type SliceOrd[A Ord[A]] []A

func (SliceOrd[A]) Compare

func (xs SliceOrd[A]) Compare(ys SliceOrd[A]) Ordering

func (SliceOrd[A]) Equal

func (xs SliceOrd[A]) Equal(ys SliceOrd[A]) bool

Jump to

Keyboard shortcuts

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