Currying a function n times in Scheme

Posted by user1724421 on Stack Overflow See other posts from Stack Overflow or by user1724421
Published on 2012-11-25T15:48:13Z Indexed on 2012/11/25 17:04 UTC
Read the original article Hit count: 344

Filed under:
|
|
|

I'm having trouble figuring out a way to curry a function a specified number of times. That is, I give the function a natural number n and a function fun, and it curries the function n times. For example:

(curry n fun)

Is the function and a possible application would be:

(((((curry 4 +) 1) 2) 3) 4)

Which would produce 10.

I'm really not sure how to implement it properly. Could someone please give me a hand? Thanks :)

© Stack Overflow or respective owner

Related posts about lambda

Related posts about Scheme