Lazy list implementation in Elm.
The lazy list type.
cons : a -> Seq a -> Seq a
Add a value to the front of a list.
empty : Seq a
Create an empty list.
singleton : a -> Seq a
Create a singleton list.
isEmpty : Seq a -> Basics.Bool
Detect if a list is empty or not.
head : Seq a -> Maybe a
Get the head of a list.
tail : Seq a -> Maybe (Seq a)
Get the tail of a list.
headAndTail : Seq a -> Maybe ( a, Seq a )
Get the head and tail of a list.
nth : Basics.Int -> Seq a -> Maybe a
Get the nth element of a list.
member : a -> Seq a -> Basics.Bool
Test if a value is a member of a list.
length : Seq a -> Basics.Int
Get the length of a lazy list - provided it is finite.
toList : Seq a -> List a
Convert a lazy list to a normal list.
fromList : List a -> Seq a
Convert a normal list to a lazy list.
toArray : Seq a -> Array a
Convert a lazy list to an array.
fromArray : Array a -> Seq a
Convert an array to a lazy list.
map : (a -> b) -> Seq a -> Seq b
Map a function over a list.
zip : Seq a -> Seq b -> Seq ( a, b )
Zip two lists together.
reduce : (a -> b -> b) -> b -> Seq a -> b
Reduce a list with a given reducer and an initial value.
Example : reduce (+) 0 (fromList [1, 2, 3, 4]) == 10
reductions : (a -> b -> b) -> b -> Seq a -> Seq b
Produce intermediate values of reduce.
flatten : Seq (Seq a) -> Seq a
Flatten a list of lists into a single list by appending all the inner lists into one big list.
append : Seq a -> Seq a -> Seq a
Append a list to another list.
foldl : (a -> b -> b) -> b -> Seq a -> b
Analogous to List.foldl
. Is an alias for reduce
.
foldr : (a -> b -> b) -> b -> Seq a -> b
Analogous to List.foldr
.
intersperse : a -> Seq a -> Seq a
Places the given value between all members of the given list.
interleave : Seq a -> Seq a -> Seq a
Interleave the elements of a list in another list. The two lists get interleaved at the end.
reverse : Seq a -> Seq a
Reverse a list.
cycle : Seq a -> Seq a
Take a list and repeat it ad infinitum.
iterate : (a -> a) -> a -> Seq a
Create an infinite list of applications of a function on some value.
Equivalent to:
cons x (cons (f x) (cons (f (f x)) (cons (f (f (f x))) ... -- etc...
repeat : a -> Seq a
Repeat a value ad infinitum.
Be careful when you use this. The result of this is a truly infinite list.
Do not try calling reduce
or toList
on an infinite list as it'll never
finish computing. Make sure you then filter it down to a finite list with head
or take
or something.
take : Basics.Int -> Seq a -> Seq a
Take at most n
many values from a list.
takeWhile : (a -> Basics.Bool) -> Seq a -> Seq a
Take elements from a list as long as the predicate is satisfied.
drop : Basics.Int -> Seq a -> Seq a
Drop at most n
many values from a list.
dropWhile : (a -> Basics.Bool) -> Seq a -> Seq a
Drop elements from a list as long as the predicate is satisfied.
keepIf : (a -> Basics.Bool) -> Seq a -> Seq a
Keep all elements in a list that satisfy the given predicate.
dropIf : (a -> Basics.Bool) -> Seq a -> Seq a
Drop all elements in a list that satisfy the given predicate.
filterMap : (a -> Maybe b) -> Seq a -> Seq b
Map a function that may fail over a lazy list, keeping only the values that were successfully transformed.
unique : Seq a -> Seq a
Remove all duplicates from a list and return a list of distinct elements.
andMap : Seq a -> Seq (a -> b) -> Seq b
Known as mapN
in some circles. Allows you to apply map
in cases
where then number of arguments are greater than 5.
The argument order is such that it works well with |>
chains.
andThen : (a -> Seq b) -> Seq a -> Seq b
Chain list producing operations. Map then flatten.
numbers : Seq number
The infinite list of counting numbers.
i.e.:
cons 1 (cons 2 (cons 3 (cons 4 (cons 5 ... -- etc...
sum : Seq number -> number
Get the sum of a list of numbers.
product : Seq number -> number
Get the product of a list of numbers.
map2 : (a -> b -> c) -> Seq a -> Seq b -> Seq c
Map a function over 2 lists.
map3 : (a -> b -> c -> d) -> Seq a -> Seq b -> Seq c -> Seq d
Map a function over 3 lists.
product2 : Seq a -> Seq b -> Seq ( a, b )
Create a lazy list containing all possible pairs in the given lazy lists.
product3 : Seq a -> Seq b -> Seq c -> Seq ( a, b, c )
Create a lazy list containing all possible triples in the given lazy lists.