singleton 42
|> toList == [42]
cons (singleton 1) (singleton 2)
|> toList == [1, 2]
append (range 1 3) (range 4 6)
|> toList == [1, 2, 3, 4, 5, 6]
empty
|> toList == []
range 1 10
|> takeWhile (\n -> n < 6)
|> toList == [1, 2, 3, 4, 5]
-- Convert list of words to stream of letters
["hello", "there"]
|> fromList
|> concatMap (\word -> word |> String.split "" |> fromList)
|> toList == ["h", "e", "l", "l", "o", "t", "h", "e", "r", "e"]
-- Flatten inner stream ranges
range 1 3
|> concatMap (\n -> range n (n + 2))
|> toList == [1, 2, 3, 2, 3, 4, 3, 4, 5]
-- Skip values with `empty`
range 1 10
|> concatMap
(\n ->
if n < 6 then
empty
else
singleton n
)
|> toList [6, 7, 8, 9, 10]
- Remove incorrect example in
range
docs.
Initial release!