1 Apr 2011 10:41
[groovy-user] How to uncurry a closure
I have a curried closure, but want to change the parameter it is curried
with.
I have built a simple test to illustrate what I am trying to achieve:
class UncurryTests extends GroovyTestCase{
void test_uncurry() {
// First, create a closure and curry it
def closure = {int param -> param * 2}
def curriedClosure = closure.curry(10)
assertEquals( 20, curriedClosure() )
// Then, uncurry and call the closure with another parameter
def uncurriedClosure = curriedClosure.uncurry()
assertEquals( 200, uncurriedClosure( 100 ) )
}
}
This doesn't work since there is no "uncurry" method on CurriedClosure.
Is there a way to do this?
--
View this message in context: http://groovy.329449.n5.nabble.com/How-to-uncurry-a-closure-tp4274956p4274956.html
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
(Continue reading)
RSS Feed