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
distinct :: for_type T: (List(T)) -> List(T)
empty_list :: for_type t: () -> List(t)
flat_map :: for_type S, T: ((S) -> List(T), List(S)) -> List(T)
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

distinct

:: for_type T: (List(T)) -> List(T)

A copy of a list with all duplicates removed. Keeps items in the original order

For example

    distinct([1, 3, 1, 2, 1, 2]) = [1, 3, 2]

empty_list

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

Constructs an empty list.

Primitive function

flat_map

:: for_type S, T: ((S) -> List(T), List(S)) -> List(T)

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.2, 2026-05-24T18:22:21.779602100+02:00[Europe/Amsterdam]