Mandrake v0.0.4 Mandrake.Function

Mandrake functional functions.

Summary

Functions

Function that return always the given value

Apply the second argument to the function

Returns the composition of two functions

Returns an anonymous function that wrap the given

Function that do nothing

Functions

always(value)

Function that return always the given value.

Examples

iex>  printExample = Mandrake.Function.always("Example")
...>  printExample.()
"Example"
apply(function, value)

Apply the second argument to the function.

Examples

iex>  mod = Mandrake.Function.apply(fn arg -> -arg end, -2)
2
build_args(string, remaining)
compose(first_function, second_function)

Returns the composition of two functions.

Examples

iex>  printHello = Mandrake.Function.compose(fn x -> "Hello " <> to_string(x) end, fn y -> y + 1 end)
...>  printHello.(6)
"Hello 7"
lambda(function, arity)

Returns an anonymous function that wrap the given.

Examples

iex>  mod = Mandrake.Function.lambda("Mandrake.Math.modulo", 2)
...>  mod.(20, 5)
0
noop()

Function that do nothing

Examples

iex>  Mandrake.Function.noop()
nil