std/core/list▲toc

Standard liststd/core/types/list: V -> V functions.

.

fun char/list( lo : charstd/core/types/char: V, hi : charstd/core/types/char: V ) : liststd/core/types/list: V -> V<charstd/core/types/char: V>

Create a list of characters from lo to hi (including hi).

fun default/head( xs : liststd/core/types/list: V -> V<a>, default : a ) : a

Return the head of list with a default value in case the list is empty.

fun function/list( lo : intstd/core/types/int: V, hi : intstd/core/types/int: V, f : (intstd/core/types/int: V) -> e a ) : e liststd/core/types/list: V -> V<a>

Applies a function f to list of increasing elements from lo to hi (including both lo and hi ). If lo > hi the function returns the empty list.

fun joinsep/join( xs : liststd/core/types/list: V -> V<stringstd/core/types/string: V>, sep : stringstd/core/types/string: V ) : stringstd/core/types/string: V

Concatenate all strings in a list using a specific separator.

fun maybe/list( m : maybestd/core/types/maybe: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Convert a maybestd/core/types/maybe: V -> V type to a list type.

fun stride/list( lo : intstd/core/types/int: V, hi : intstd/core/types/int: V, stride : intstd/core/types/int: V ) : liststd/core/types/list: V -> V<intstd/core/types/int: V>

Returns an integer list of increasing elements from lo to hi with stride stride. If lo > hi the function returns the empty list.

fun stridefunction/list( lo : intstd/core/types/int: V, hi : intstd/core/types/int: V, stride : intstd/core/types/int: V, f : (intstd/core/types/int: V) -> e a ) : e liststd/core/types/list: V -> V<a>

Returns an integer list of increasing elements from lo to hi with stride stride. If lo > hi the function returns the empty list.

fun string/map( s : stringstd/core/types/string: V, f : (charstd/core/types/char: V) -> e charstd/core/types/char: V ) : e stringstd/core/types/string: V

Apply a function f to each character in a string.

fun (++)( xs : liststd/core/types/list: V -> V<a>, ys : liststd/core/types/list: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Append two lists.

fun (==)( xs : liststd/core/types/list: V -> V<a>, ys : liststd/core/types/list: V -> V<a>, ?(==) : (a, a) -> boolstd/core/types/bool: V ) : boolstd/core/types/bool: V

Element-wise list equality.

fun all( xs : liststd/core/types/list: V -> V<a>, predicate : (a) -> e boolstd/core/types/bool: V ) : e boolstd/core/types/bool: V

Do all elements satisfy a predicate ?

fun any( xs : liststd/core/types/list: V -> V<a>, predicate : (a) -> e boolstd/core/types/bool: V ) : e boolstd/core/types/bool: V

Are there any elements in a list that satisfy a predicate ?

fun append( xs : liststd/core/types/list: V -> V<a>, ys : liststd/core/types/list: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Append two lists.

fun cmp( xs : liststd/core/types/list: V -> V<a>, ys : liststd/core/types/list: V -> V<a>, ?cmp : (a, a) -> orderstd/core/types/order: V ) : orderstd/core/types/order: V

Order on lists.

fun concat( xss : liststd/core/types/list: V -> V<liststd/core/types/list: V -> V<a>> ) : liststd/core/types/list: V -> V<a>

Concatenate all lists in a list (e.g. flatten the list). (tail-recursive).

fun concat-maybe( xs : liststd/core/types/list: V -> V<maybestd/core/types/maybe: V -> V<a>> ) : liststd/core/types/list: V -> V<a>

Concatenate a list of maybestd/core/types/maybe: V -> V values.

fun drop( xs : liststd/core/types/list: V -> V<a>, n : intstd/core/types/int: V ) : liststd/core/types/list: V -> V<a>

Drop the first n elements of a list (or fewer if the list is shorter than n).

fun drop-while( xs : liststd/core/types/list: V -> V<a>, predicate : (a) -> e boolstd/core/types/bool: V ) : e liststd/core/types/list: V -> V<a>

Drop all initial elements that satisfy predicate.

fun filter( xs : liststd/core/types/list: V -> V<a>, pred : (a) -> e boolstd/core/types/bool: V ) : e liststd/core/types/list: V -> V<a>

Retain only those elements of a list that satisfy the given predicate pred. For example: filterstd/core/list/filter: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e list<a>([1,2,3],odd?) == [1,3].

fun filter-map( xs : liststd/core/types/list: V -> V<a>, pred : (a) -> e maybestd/core/types/maybe: V -> V<b> ) : e liststd/core/types/list: V -> V<b>

Retain only those elements of a list that satisfy the given predicate pred. For example: filterMap([1,2,3],fn(i) { if i.odd? then Nothingstd/core/types/Nothing: forall<a> maybe<a> else Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(i(*)std/core/int/(*): (int, int) -> inti) }) == [4].

fun find( xs : liststd/core/types/list: V -> V<a>, pred : (a) -> e boolstd/core/types/bool: V ) : e maybestd/core/types/maybe: V -> V<a>

Find the first element satisfying some predicate.

fun find-maybe( xs : liststd/core/types/list: V -> V<a>, pred : (a) -> e maybestd/core/types/maybe: V -> V<b> ) : e maybestd/core/types/maybe: V -> V<b>

Find the first element satisfying some predicate and return it.

fun flatmap( xs : liststd/core/types/list: V -> V<a>, f : (a) -> e liststd/core/types/list: V -> V<b> ) : e liststd/core/types/list: V -> V<b>

Concatenate the result lists from applying a function to all elements.

fun flatmap-maybe( xs : liststd/core/types/list: V -> V<a>, f : (a) -> e maybestd/core/types/maybe: V -> V<b> ) : e liststd/core/types/list: V -> V<b>

Concatenate the Juststd/core/types/Just: forall<a> (value : a) -> maybe<a> result elements from applying a function to all elements.

fun foldl( xs : liststd/core/types/list: V -> V<a>, z : b, f : (b, a) -> e b ) : e b

Fold a list from the left, i.e. foldlstd/core/list/foldl: forall<a,b,e> (xs : list<a>, z : b, f : (b, a) -> e b) -> e b([1,2],0,(+)) == (0+1)+2 Since foldlstd/core/list/foldl: forall<a,b,e> (xs : list<a>, z : b, f : (b, a) -> e b) -> e b is tail recursive, it is preferred over foldrstd/core/list/foldr: forall<a,b,e> (xs : list<a>, z : b, f : (a, b) -> e b) -> e b when using an associative function f.

fun foldl1( xs : liststd/core/types/list: V -> V<a>, f : (a, a) -> <exnstd/core/exn/exn: (E, V) -> V|e> a ) : <exnstd/core/exn/exn: (E, V) -> V|e> a
fun foldr( xs : liststd/core/types/list: V -> V<a>, z : b, f : (a, b) -> e b ) : e b

Fold a list from the right, i.e. foldrstd/core/list/foldr: forall<a,b,e> (xs : list<a>, z : b, f : (a, b) -> e b) -> e b([1,2],0,(+)) == 1+(2+0) Note, foldrstd/core/list/foldr: forall<a,b,e> (xs : list<a>, z : b, f : (a, b) -> e b) -> e b is less efficient than foldlstd/core/list/foldl: forall<a,b,e> (xs : list<a>, z : b, f : (b, a) -> e b) -> e b as it reverses the list first.

fun foldr1( xs : liststd/core/types/list: V -> V<a>, f : (a, a) -> <exnstd/core/exn/exn: (E, V) -> V|e> a ) : <exnstd/core/exn/exn: (E, V) -> V|e> a
fun foreach( xs : liststd/core/types/list: V -> V<a>, action : (a) -> e () ) : e ()

Invoke action for each element of a list.

fun foreach-indexed( xs : liststd/core/types/list: V -> V<a>, action : (intstd/core/types/int: V, a) -> e () ) : e ()

Invoke action for each element of a list, passing also the position of the element.

fun foreach-while( xs : liststd/core/types/list: V -> V<a>, action : (a) -> e maybestd/core/types/maybe: V -> V<b> ) : e maybestd/core/types/maybe: V -> V<b>

Invoke action for each element of a list while action return Nothingstd/core/types/Nothing: forall<a> maybe<a>.

fun index-of( xs : liststd/core/types/list: V -> V<a>, pred : (a) -> e boolstd/core/types/bool: V ) : e intstd/core/types/int: V

Returns the index of the first element where pred holds, or -1 if no such element exists.

fun init( xs : liststd/core/types/list: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Return the list without its last element. Return an empty list for an empty list.

fun intersperse( xs : liststd/core/types/list: V -> V<a>, sep : a ) : liststd/core/types/list: V -> V<a>

Insert a separator sep between all elements of a list xs .

fun is-empty( xs : liststd/core/types/list: V -> V<a> ) : boolstd/core/types/bool: V

Is the list empty?

fun join( xs : liststd/core/types/list: V -> V<stringstd/core/types/string: V> ) : stringstd/core/types/string: V

Concatenate all strings in a list.

fun join-end( xs : liststd/core/types/list: V -> V<stringstd/core/types/string: V>, end : stringstd/core/types/string: V ) : stringstd/core/types/string: V

Append end to each string in the list xs and join them all together.
join-endstd/core/list/join-end: (xs : list<string>, end : string) -> string([],end) === ""
join-endstd/core/list/join-end: (xs : list<string>, end : string) -> string(["a","b"],"/") === "a/b/".

fun last( xs : liststd/core/types/list: V -> V<a> ) : maybestd/core/types/maybe: V -> V<a>

Return the last element of a list (or Nothingstd/core/types/Nothing: forall<a> maybe<a> for the empty list).

fun length( xs : liststd/core/types/list: V -> V<a> ) : intstd/core/types/int: V

Returns the length of a list.

fun lines( s : stringstd/core/types/string: V ) : liststd/core/types/list: V -> V<stringstd/core/types/string: V>

Split a string into a list of lines.

fun list( lo : intstd/core/types/int: V, hi : intstd/core/types/int: V ) : liststd/core/types/list: V -> V<intstd/core/types/int: V>

Returns an integer list of increasing elements from lo to hi (including both lo and hi ). If lo > hi the function returns the empty list.

fun lookup( xs : liststd/core/types/list: V -> V<(a, b)>, pred : (a) -> e boolstd/core/types/bool: V ) : e maybestd/core/types/maybe: V -> V<b>

Lookup the first element satisfying some predicate.

fun map( xs : liststd/core/types/list: V -> V<a>, f : (a) -> e b ) : e liststd/core/types/list: V -> V<b>

Apply a function f to each element of the input list in sequence.

fun map-indexed( xs : liststd/core/types/list: V -> V<a>, f : (idx : intstd/core/types/int: V, value : a) -> e b ) : e liststd/core/types/list: V -> V<b>

Apply a function f to each element of the input list in sequence where takes both the index of the current element and the element itself as arguments.

fun map-indexed-peek( xs : liststd/core/types/list: V -> V<a>, f : (idx : intstd/core/types/int: V, value : a, rest : liststd/core/types/list: V -> V<a>) -> e b ) : e liststd/core/types/list: V -> V<b>

Apply a function f to each element of the input list in sequence where takes both the index of the current element, the element itself, and the tail list as arguments.

fun map-peek( xs : liststd/core/types/list: V -> V<a>, f : (value : a, rest : liststd/core/types/list: V -> V<a>) -> e b ) : e liststd/core/types/list: V -> V<b>

Apply a function f to each element of the input list in sequence where f takes both the current element and the tail list as arguments.

fun map-while( xs : liststd/core/types/list: V -> V<a>, action : (a) -> e maybestd/core/types/maybe: V -> V<b> ) : e liststd/core/types/list: V -> V<b>

Invoke action on each element of a list while action returns Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>.

fun maximum( xs : liststd/core/types/list: V -> V<intstd/core/types/int: V>, default : ? intstd/core/types/int: V ) : intstd/core/types/int: V

Returns the largest element of a list of integers (or defaultstd/core/exn/default: forall<a> (t : error<a>, def : a) -> a (=0) for the empty list).

fun minimum( xs : liststd/core/types/list: V -> V<intstd/core/types/int: V>, default : ? intstd/core/types/int: V ) : intstd/core/types/int: V

Returns the smallest element of a list of integers (or defaultstd/core/exn/default: forall<a> (t : error<a>, def : a) -> a (=0) for the empty list).

fun partition( xs : liststd/core/types/list: V -> V<a>, ^pred : (a) -> e boolstd/core/types/bool: V ) : e (liststd/core/types/list: V -> V<a>, liststd/core/types/list: V -> V<a>)

Partition a list in two lists where the first list contains those elements that satisfy the given predicate pred. For example: partitionstd/core/list/partition: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e (list<a>, list<a>)([1,2,3],odd?) == ([1,3],[2]).

fun remove( xs : liststd/core/types/list: V -> V<a>, pred : (a) -> e boolstd/core/types/bool: V ) : e liststd/core/types/list: V -> V<a>

Remove those elements of a list that satisfy the given predicate pred. For example: removestd/core/list/remove: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e list<a>([1,2,3],odd?) == [2].

fun replicate( x : a, n : intstd/core/types/int: V ) : liststd/core/types/list: V -> V<a>

Create a list of n repeated elements x.

fun reverse( xs : liststd/core/types/list: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Reverse a list.

fun reverse-append( xs : liststd/core/types/list: V -> V<a>, tl : liststd/core/types/list: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Efficiently reverse a list xs and append it to tl: reverse-appendstd/core/list/reverse-append: forall<a> (xs : list<a>, tl : list<a>) -> list<a>(xs,tl) == reserve(xs) ++ tl.

fun reverse-join( xs : liststd/core/types/list: V -> V<stringstd/core/types/string: V> ) : stringstd/core/types/string: V

Concatenate all strings in a list in reverse order.

fun show( xs : liststd/core/types/list: V -> V<a>, ?show : (a) -> e stringstd/core/types/string: V ) : e stringstd/core/types/string: V

Show a list.

fun show-list( xs : liststd/core/types/list: V -> V<a>, show-elem : (a) -> e stringstd/core/types/string: V ) : e stringstd/core/types/string: V

deprecated, use showstd/core/list/show: forall<a,e> (xs : list<a>, @implicit/show : (a) -> e string) -> e string instead.

fun single( x : a ) : liststd/core/types/list: V -> V<a>

Returns a singleton list.

fun span( xs : liststd/core/types/list: V -> V<a>, predicate : (a) -> e boolstd/core/types/bool: V ) : e (liststd/core/types/list: V -> V<a>, liststd/core/types/list: V -> V<a>)
fun split( xs : liststd/core/types/list: V -> V<a>, n : intstd/core/types/int: V ) : (liststd/core/types/list: V -> V<a>, liststd/core/types/list: V -> V<a>)

Split a list at position n.

fun sum( xs : liststd/core/types/list: V -> V<intstd/core/types/int: V> ) : intstd/core/types/int: V

Return the sum of a list of integers.

fun tail( xs : liststd/core/types/list: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Return the tail of list. Returns the empty list if xs is empty.

fun take( xs : liststd/core/types/list: V -> V<a>, n : intstd/core/types/int: V ) : liststd/core/types/list: V -> V<a>

Take the first n elements of a list (or fewer if the list is shorter than n).

fun take-while( xs : liststd/core/types/list: V -> V<a>, predicate : (a) -> e boolstd/core/types/bool: V ) : e liststd/core/types/list: V -> V<a>

Keep only those initial elements that satisfy predicate.

fun unlines( xs : liststd/core/types/list: V -> V<stringstd/core/types/string: V> ) : stringstd/core/types/string: V

Join a list of strings with newlines.

fun unzip( xs : liststd/core/types/list: V -> V<(a, b)> ) : (liststd/core/types/list: V -> V<a>, liststd/core/types/list: V -> V<b>)

Unzip a list of pairs into two lists.

fun unzip3( xs : liststd/core/types/list: V -> V<(a, b, c)> ) : (liststd/core/types/list: V -> V<a>, liststd/core/types/list: V -> V<b>, liststd/core/types/list: V -> V<c>)

Unzip a list of triples into three lists.

fun unzip4( xs : liststd/core/types/list: V -> V<(a, b, c, d)> ) : (liststd/core/types/list: V -> V<a>, liststd/core/types/list: V -> V<b>, liststd/core/types/list: V -> V<c>, liststd/core/types/list: V -> V<d>)

Unzip a list of quadruples into four lists.

fun zip( xs : liststd/core/types/list: V -> V<a>, ys : liststd/core/types/list: V -> V<b> ) : liststd/core/types/list: V -> V<(a, b)>

Zip two lists together by pairing the corresponding elements. The returned list is only as long as the smallest input list.

fun zipwith( xs : liststd/core/types/list: V -> V<a>, ys : liststd/core/types/list: V -> V<b>, f : (a, b) -> e c ) : e liststd/core/types/list: V -> V<c>

Zip two lists together by apply a function f to all corresponding elements. The returned list is only as long as the smallest input list.

fun zipwith-indexed( xs0 : liststd/core/types/list: V -> V<a>, ys0 : liststd/core/types/list: V -> V<b>, f : (intstd/core/types/int: V, a, b) -> e c ) : e liststd/core/types/list: V -> V<c>

Zip two lists together by apply a function f to all corresponding elements and their index in the list. The returned list is only as long as the smallest input list.

private import std/core/typesstd/core/types, std/core/undivstd/core/undiv, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/charstd/core/char, std/core/stringstd/core/string, std/core/intstd/core/int, std/core/vectorstd/core/vector