3 ms·
I expect this to be useful, enough so that I planned on adding it to a (non-CL) language implementation. (But it hasn't happened yet, so I can't report from exp
by cronjobber 10y ago
I expect this to be useful, enough so that I planned on adding it to a (non-CL) language implementation. (But it hasn't happened yet, so I can't report from experience.)
BTW, while everybody in this thread seems to think that partial application is all there is to Haskell style currying, it isn't. Consider
(defun foo (x) (lambda (y) (+ x y)))
If you can't call this as
(foo 1 2)
to get 3, you still don't really have currying.
- kazinator 10y agoWe cannot call that foo as (foo) either, so we have nothing. We have to do something in foo to make currying work. If (foo 1) is required to return a unary function, of course we support (foo 1 2) which passes 2 to that function. Here is the problem case: (defun foo (x) (unknown x)) Suppose unknown can return a function of any number of arguments. The developer of foo doesn't know how many. If it returns a five-argument function, you expect the call (foo 1 2 3 4 5 6) to work. Basically, we can make foo n-ary such that it calls unknown with the first arg, and passes the rest to the function that unknown returns. A subtlety not mentioned in the thread is that (x) and x are distinct in Lisps. Applying an empty argument list is different from not applying arguments.