"Autocurrying?"
Posted: Fri Feb 15, 2008 7:15 pm
I've started to learn F# (a OCaml-like language for .NET), and one feature that really struck me is automatic currying. Here's a newLISP-syntax example of what I mean (it is not valid newLISP code):
Basically, when you "call" a function without supplying it every argument, it returns a curried function that expects the takes the next arguments.
Could something like this be added to newLISP? I realize that breaking current code is bad, but there could be an "autocurry" macro:
I've tried to implement an autocurry in newLISP, but hit a wall because it's difficult to differentiate between a "nil" passed by default and a "nil" passed by the caller.
Code: Select all
(define (add-nums a b)
(+ a b)
(setq add10 (add-nums 10))
(add10 3) ; => 13
Could something like this be added to newLISP? I realize that breaking current code is bad, but there could be an "autocurry" macro:
Code: Select all
(define (add-nums a b)
(+ a b))
(autocurry add-nums)