This module adds support for currying to Nim.
- Currying a proc with N parameters transforms it into one that:
- takes 1 parameter.
- returns another proc that takes 1 parameter.
- and so on for each remaining parameter.
Since 0.3.0.
Templates
template curry(self: untyped{nkLambda}): auto
-
Transforms an anonymous proc into a curried one.
Only procedures having 2 or more parameters are affected.
auto return type is currently not supported.
- Example:
import pkg/funcynim/[curry] let f = proc (item: string; s: seq[string]): seq[string] {.curry.} = s & item addB = f("b") assert(@["a"].addB() == @["a", "b"])
Since 0.3.0.
Source Edit template curry(self: untyped{nkProcDef | nkFuncDef}): auto
-
Transforms a proc or func definition into a curried one.
Only procedures having 2 or more parameters are affected.
- Example:
import pkg/funcynim/[curry] proc `+`[T](item: T; self: seq[T]): seq[T] {.curry.} = self & item let addB = + "b" assert(@["a"].addB() == @["a", "b"])
Since 0.3.0.
Source Edit