Wonderland v0.1.0 Wonderland.Combinator View Source
Basic functional programming combinators
Link to this section Summary
Functions
Classic composition function
Constant function, ignores 2nd argument
Identity function
Creates Thunk from expression
Recursively evaluates Thunk
Link to this section Functions
Classic composition function
Examples
iex> x = compose(&(&1+1), &(&1*2))
iex> x.(42)
85
Constant function, ignores 2nd argument
Examples
iex> const(:foo, :bar)
:foo
iex> const(:foo).(:bar)
:foo
Identity function
Examples
iex> id(:hello)
:hello
Creates Thunk from expression
Examples
iex> x = "BOOM" |> raise |> lazy
iex> Thunk.is?(x)
true
Recursively evaluates Thunk
Examples
iex> x = 2 * 2 |> lazy
iex> y = "BOOM" |> raise |> lazy
iex> strict(x)
4
iex> strict(y)
** (RuntimeError) BOOM