Quark v1.0.1 Quark.Curry
Currying breaks up a function into a series of unary functions that apply their arguments to some inner n-ary function. This is a convenient way to achieve a general and flexble partial application on any curried function.
Summary
Functions
This allows you to curry a function at runtime, rather than upon definition
Convert a curried function to a function on pairs
Apply an argument to a function
Functions
Specs
curry((... -> any)) :: (any -> any)
This allows you to curry a function at runtime, rather than upon definition.
iex> curried_reduce_3 = curry &Enum.reduce/3
iex> {_, arity} = :erlang.fun_info(curried_reduce_3, :arity)
iex> arity
1
iex> curried_reduce_3 = curry &Enum.reduce/3
iex> import Quark.Curry
iex> curried_reduce_3.([1,2,3]).(42).(&(&1 + &2))
48
Specs
uncurry((any -> (any -> any))) :: (any, any -> any)
Convert a curried function to a function on pairs
iex> curried_add = fn x -> (fn y -> x + y end) end
iex> add = uncurry curried_add
iex> add.(1,2)
3