Quark v1.0.1 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 example, defpartial foo(a, b, c), do: a + b + c will generate 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. For instance, defpartial add(a,b), do: a + b will generate add/0,
add/1 and add/2
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 will generate add/0,
add/1 and add/2.
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