FunFunc v0.2.0 FunFunc.Func

Functions for generic purpose.

Link to this section Summary

Functions

Applys args to the curried function

Composition function

Constant function. It returns the first argument

Curry function

Flip function

Identity function. It always returns the argument

Ignore function. It returns the second argument

Return function. It returns the argument on the call

Link to this section Functions

Link to this function apply_args(f, args)
apply_args((... -> any()), list()) :: any()

Applys args to the curried function.

Examples

iex> f = fn a -> fn b -> fn c -> a + b + c end end end
iex> FunFunc.Func.apply_args(f, [1, 2, 3])
6
Link to this function compose(f, g)
compose((... -> any()), (... -> any())) :: (... -> any())

Composition function.

Examples

iex> FunFunc.Func.compose(&String.to_integer/1, &Integer.to_string/1).(1)
1
Link to this function const(x)
const(any()) :: (... -> any())

Constant function. It returns the first argument.

Examples

iex> FunFunc.Func.const(1).(2)
1
Link to this function curry(f)
curry((... -> any())) :: (... -> any())

Curry function.

Examples

iex> FunFunc.Func.curry(&(&1 + &2)).(1).(2)
3
iex> FunFunc.Func.curry(&(&1 + &2 + &3)).(1).(2).(3)
6
Link to this function flip(f)
flip((... -> any())) :: (... -> any())

Flip function.

Examples

iex> FunFunc.Func.flip(&-/2).(1, 2)
1
Link to this function id()
id() :: (... -> any())

Identity function. It always returns the argument.

Examples

iex> FunFunc.Func.id().(1)
1
Link to this function ignore(x)
ignore(any()) :: (... -> any())

Ignore function. It returns the second argument.

Examples

iex> FunFunc.Func.ignore(1).(2)
2
Link to this function return(x)
return(any()) :: (... -> any())

Return function. It returns the argument on the call.

Examples

iex> FunFunc.Func.return(1).()
1