groovy

Closures should have rcurry and ncurry as well as curry

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7.1
  • Fix Version/s: 1.7.2, 1.8-beta-1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

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)

Activity

Hide
Paul King added a comment -

Leaving out of 1_6_X for now.

Show
Paul King added a comment - Leaving out of 1_6_X for now.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: