lux/data/struct/list

Macros

zip

## Create list zippers with the specified number of input lists.
(def: #export zip2 (zip 2))

(def: #export zip3 (zip 3))

((zip 3) xs ys zs)

zip-with

## Create list zippers with the specified number of input lists.
(def: #export zip2-with (zip-with 2))

(def: #export zip3-with (zip-with 3))

((zip-with 2) i.+ xs ys)

Structs

Applicative<List>

(lux/control/applicative;Applicative lux;List)

(Eq<List> Eq<a>)

(All [a] (-> (lux/control/eq;Eq a) (lux/control/eq;Eq (lux;List a))))

Fold<List>

(lux/control/fold;Fold lux;List)

Functor<List>

(lux/control/functor;Functor lux;List)

(ListT Monad<M>)

(All [a] (-> (lux/control/monad;Monad a) (lux/control/monad;Monad (All [b] (a (lux;List b))))))

Monad<List>

(lux/control/monad;Monad lux;List)

Monoid<List>

(All [a] (lux/control/monoid;Monoid (lux;List a)))

Values

(any? p xs)

(All [a] (-> (-> a lux;Bool) (lux;List a) lux;Bool))

(as-pairs xs)

Cut the list into pairs of 2.

Caveat emptor: If the list has an uneven number of elements, the last one will be skipped.

(All [a] (-> (lux;List a) (lux;List [a a])))

(at i xs)

Fetches the element at the specified index.

(All [a] (-> lux;Nat (lux;List a) (lux;Maybe a)))

(concat xss)

(All [a] (-> (lux;List (lux;List a)) (lux;List a)))

(drop n xs)

(All [a] (-> lux;Nat (lux;List a) (lux;List a)))

(drop-while p xs)

(All [a] (-> (-> a lux;Bool) (lux;List a) (lux;List a)))

(empty? xs)

(All [a] (-> (lux;List a) lux;Bool))

(enumerate xs)

Pairs every element in the list with it's index, starting at 0.

(All [a] (-> (lux;List a) (lux;List [lux;Nat a])))

(every? p xs)

(All [a] (-> (-> a lux;Bool) (lux;List a) lux;Bool))

(filter p xs)

(All [a] (-> (-> a lux;Bool) (lux;List a) (lux;List a)))

(find p xs)

Returns the first value in the list for which the predicate is true.

(All [a] (-> (-> a lux;Bool) (lux;List a) (lux;Maybe a)))

(head xs)

Returns the first element of a list.

(All [a] (-> (lux;List a) (lux;Maybe a)))

(i.range from to)

Generates an inclusive interval of values [from, to].

(-> lux;Int lux;Int (lux;List lux;Int))

(indices size)

Produces all the valid indices for a given size.

(All [a] (-> lux;Nat (lux;List lux;Nat)))

(inits xs)

For a list of size N, returns the first N-1 elements.

Empty lists will result in a #;None value being returned instead.

(All [a] (-> (lux;List a) (lux;Maybe (lux;List a))))

(interpose sep xs)

Puts a value between every two elements in the list.

(All [a] (-> a (lux;List a) (lux;List a)))

(iterate f x)

Generates a list element by element until the function returns #;None.

(All [a] (-> (-> a (lux;Maybe a)) a (lux;List a)))

(last xs)

(All [a] (-> (lux;List a) (lux;Maybe a)))

(lift-list Monad<M>)

(All [a b] (-> (lux/control/monad;Monad a) (a b) (a (lux;List b))))

(member? eq xs x)

(All [a] (-> (lux/control/eq;Eq a) (lux;List a) a lux;Bool))

(n.range from to)

Generates an inclusive interval of values [from, to].

(-> lux;Nat lux;Nat (lux;List lux;Nat))

(partition p xs)

Divide the list into all elements that satisfy a predicate, and all elements that don't.

(All [a] (-> (-> a lux;Bool) (lux;List a) [(lux;List a) (lux;List a)]))

(repeat n x)

A list of the value x, repeated n times.

(All [a] (-> lux;Nat a (lux;List a)))

(reverse xs)

(All [a] (-> (lux;List a) (lux;List a)))

(size list)

(All [a] (-> (lux;List a) lux;Nat))

(sort < xs)

(All [a] (-> (-> a a lux;Bool) (lux;List a) (lux;List a)))

(split n xs)

(All [a] (-> lux;Nat (lux;List a) [(lux;List a) (lux;List a)]))

(split-all n xs)

Segment the list in chunks of size n.

(All [a] (-> lux;Nat (lux;List a) (lux;List (lux;List a))))

(split-with p xs)

Segment the list by using a predicate to tell when to cut.

(All [a] (-> (-> a lux;Bool) (lux;List a) [(lux;List a) (lux;List a)]))

(tail xs)

For a list of size N, returns the N-1 elements after the first one.

(All [a] (-> (lux;List a) (lux;Maybe (lux;List a))))

(take n xs)

(All [a] (-> lux;Nat (lux;List a) (lux;List a)))

(take-while p xs)

(All [a] (-> (-> a lux;Bool) (lux;List a) (lux;List a)))

zip2

(All [a b] (-> (lux;List a) (lux;List b) (lux;List [a b])))

zip2-with

(All [a b c] (-> (-> a b c) (lux;List a) (lux;List b) (lux;List c)))

zip3

(All [a b c] (-> (lux;List a) (lux;List b) (lux;List c) (lux;List [a b c])))

zip3-with

(All [a b c d] (-> (-> a b c d) (lux;List a) (lux;List b) (lux;List c) (lux;List d)))