Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.1
-
None
-
None
Description
Sometimes you don't want to curry from the left hand side. You can always fake it by rewriting a reversed method or Closure manually but most functional languages support currying from the right or an arbitrary index.
An rcurry method allows examples like this:
def divide = { a, b -> a / b }
def halver = divide.rcurry(2)
assert halver(8) == 4
An ncurry method would allow, as an example, to curry the middle parameter of a three argument method, e.g.:
// curry middle param of this utility method: // Collections#binarySearch(List list, Object key, Comparator c) def catSearcher = Collections.&binarySearch.ncurry(1, "cat") def result = catSearcher(myList, myComparator)