[Haskell-cafe] Currying function using values from array

Sukit Tretriluxana tretriluxana.s at gmail.com
Thu Aug 7 14:31:10 EDT 2008


Dear Haskell experts,

I am currently studying Groovy language. An experiment I did with its
closure is to perform closure/function "curry" using an array containing the
values for the parameter binding. See the sample below.

int addThemUp(a,b,c,d,e) { a+b+c+d+e }
def arrayCurry(arr, cls) { arr.inject(cls) { c, v -> c.curry(v) } }
println addThemUp(1,2,3,4,5)
println arrayCurry([1,2,3,4,5], this.&addThemUp)()
println arrayCurry([1,2,3,4], this.&addThemUp)(5)

The printouts from the above code are the same, verifying that the code
works fine. Then I come to ask myself how I can do the same in Haskell. I'm
not a Haskell expert so I couldn't figure it. I wonder if you guys could
shed some light on this.

Thanks,
Ed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080807/a2c34609/attachment.htm


More information about the Haskell-Cafe mailing list