
7 Aug
2008
7 Aug
'08
2:31 p.m.
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