The list library

Functions for the List type.

Synopsis

append :: for_type t: (List(t), List(t)) -> List(t)
combis :: for_type t: (List(t)) -> List(Tuple(t, t))
cons :: for_type t: (t, List(t)) -> List(t)
contains :: for_type t: (List(t), t) -> Boole
empty_list :: for_type t: () -> List(t)
flat_map :: for_type a, b: ((a) -> List(b), List(a)) -> List(b)
flatten :: for_type t: (List(List(t))) -> List(t)
fold_list :: for_type t: ((t, t) -> t, List(t)) -> t
head :: for_type t: (List(t)) -> t
list_size :: for_type t: (List(t)) -> 1
loop_list :: for_type a, t: (a, (a, t) -> a, List(t)) -> a
map_list :: for_type s, t: ((s) -> t, List(s)) -> List(t)
naturals :: (1) -> List(1)
nth :: for_type t: (1, List(t)) -> t
remove_nth :: for_type t: (1, List(t)) -> List(t)
reverse :: for_type t: (List(t)) -> List(t)
scanl :: for_type s, t: ((t, s) -> t, t, List(s)) -> List(t)
scanl1 :: for_type t: ((t, t) -> t, List(t)) -> List(t)
singleton_list :: for_type t: (t) -> List(t)
sort_list :: for_type t: (List(t), (t, t) -> 1) -> List(t)
tail :: for_type t: (List(t)) -> List(t)
unzip :: for_type s, t: (List(Tuple(s, t))) -> Tuple(List(s), List(t))
zip :: for_type s, t: (List(s), List(t)) -> List(Tuple(s, t))
zip_with :: for_type s, t, u: ((s, t) -> u, List(s), List(t)) -> List(u)

Functions

append

:: for_type t: (List(t), List(t)) -> List(t)

A list that is the concatenation of the two given lists.

Primitive function

combis

:: for_type t: (List(t)) -> List(Tuple(t, t))

A list of pairs containing all combinations of elements from the two given lists.

For example combis([1,2,3]) contains the elements (1,2), (1,3) and (2,3).

The order is undefined.

cons

:: for_type t: (t, List(t)) -> List(t)

Addes an element to the head of the list.

Primitive function

contains

:: for_type t: (List(t), t) -> Boole

Checks if the element is member of the list.

Primitive function

empty_list

:: for_type t: () -> List(t)

Constructs an empty list.

Primitive function

flat_map

:: for_type a, b: ((a) -> List(b), List(a)) -> List(b)

Combines flatten and map.

flatten

:: for_type t: (List(List(t))) -> List(t)

Turns a list of lists into a list. All lists are appened.

fold_list

:: for_type t: ((t, t) -> t, List(t)) -> t

Folds the list with the given function.

Primitive function

:: for_type t: (List(t)) -> t

The head element of the list (the last consed value).

It is an error if the list is empty.

Primitive function

list_size

:: for_type t: (List(t)) -> 1

The number of elements in the list.

Primitive function

loop_list

:: for_type a, t: (a, (a, t) -> a, List(t)) -> a

Calls the given accumulator function for each element of the list and the accumulated value. Starts with the initial value.

Primitive function

map_list

:: for_type s, t: ((s) -> t, List(s)) -> List(t)

Applies the given function to each element of a list.

Primitive function

naturals

:: (1) -> List(1)

The first x naturals numbers.

Primitive function

nth

:: for_type t: (1, List(t)) -> t

The nth element of the list.

It is an error if the index is out of bounds.

Primitive function

remove_nth

:: for_type t: (1, List(t)) -> List(t)

Copy of the given list with the n-th element removed.

reverse

:: for_type t: (List(t)) -> List(t)

The list in reversed order.

Primitive function

scanl

:: for_type s, t: ((t, s) -> t, t, List(s)) -> List(t)

scanl1

:: for_type t: ((t, t) -> t, List(t)) -> List(t)

singleton_list

:: for_type t: (t) -> List(t)

A list containing the given item.

Primitive function

sort_list

:: for_type t: (List(t), (t, t) -> 1) -> List(t)

Sorts the list with the given order. The order function must return negative, 0 or positive to indicate less, equal or greater.

Primitive function

tail

:: for_type t: (List(t)) -> List(t)

Copy of the list without the head element.

Primitive function

unzip

:: for_type s, t: (List(Tuple(s, t))) -> Tuple(List(s), List(t))

Turns a list of pairs into a pair of lists.

zip

:: for_type s, t: (List(s), List(t)) -> List(Tuple(s, t))

Turns a pair of lists into a list of pairs. Each element from the first list is coupled with the corresponding element from the second list.

Primitive function

zip_with

:: for_type s, t, u: ((s, t) -> u, List(s), List(t)) -> List(u)

Applies the given function to corresponding pairs of elements from the two given lists.

Version v0.6.0, 2026-03-05T15:49:19.127292168+01:00[Europe/Amsterdam]