Curry

Simple module for currying functions.

Source

Summary

curry(fun)

Curries a given function

Macros

curry(fun)

Curries a given function.

A function that would normally take three parameters, for example, will take three individual parameters instead. The curry macro works with anonymous functions and captured named functions.

Examples

iex> fun3 = &(&1 + &2 + &3)
iex> fun3.(3, 4, 5)
12
iex> curried3 = curry(fun3)
iex> curried3.(3).(4).(5)
12

iex> defmodule Curry.Sample do
...>   def uncurried(x, y, z) do
...>     x + y + z
...>   end
...> end
iex> Curry.Sample.uncurried(3, 4, 5)
12
iex> captured3 = curry &Curry.Sample.uncurried/3
iex> captured3.(3).(4).(5)
12
Source