Quark v2.2.0 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 flexible partial application on any curried function.
Summary
Functions
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)
Curry a function at runtime, rather than upon definition
Examples
iex> curried_reduce_3 = curry &Enum.reduce/3
...> {_, arity} = :erlang.fun_info(curried_reduce_3, :arity)
...> arity
1
iex> curried_reduce_3 = curry &Enum.reduce/3
...> curried_reduce_3.([1,2,3]).(42).(&(&1 + &2))
48
Specs
uncurry((any -> (... -> any))) :: (any, any -> any)
Convert a curried function to a function on pairs
Examples
iex> curried_add = fn x -> (fn y -> x + y end) end
iex> add = uncurry curried_add
iex> add.(1,2)
3