Quark v2.1.0 Quark.Partial
Provide curried functions, that can also be partially bound without dot notation. Partially applying a function will always return a fully-curried function.
Please note that these will use all of the arities up to the defined function.
For instance:
defpartial foo(a, b, c), do: a + b + c
#=> foo/0, foo/1, foo/2, and foo/3
If you need to use an arity in the range below the original
function, fall back to defcurry
and partially apply manually.
Summary
Macros
A convenience on defcurry
. Generates a series of partially-bound
applications of a fully-curried function, for all arities at and below
the user-specified arity
defpartial
, but generates private functions
Macros
A convenience on defcurry
. Generates a series of partially-bound
applications of a fully-curried function, for all arities at and below
the user-specified arity.
For instance:
defpartial add(a,b), do: a + b
#=> add/0, add/1, add/2.
Examples
defpartialp minus(a, b, c), do: a - b - c
minus(3, 2, 1)
0
minus.(3).(2).(1)
0
below_ten = minus(5)
below_ten.(2, 1)
7
below_five = minus(20, 15)
below_five.(2)
3