Function Application is not Currying

Function Application is not Currying

Post by Slobodan B » Fri, 30 Jan 2009 17:44:38



> Currying> >> > A curried function is a function which returns a function as i>s
> resul>. >>
> LOL. That is incorrect.

Good catch Xah. Currying in pseudolisp
(defun add (x y) (+ x y))
(add 2 3>
-> 5
(apply (add 2) '(3))
(add 2) ; since argument is missing it returns a function that adds
its argument to 2
5
Not currying:
(defun foo (x)
(if (oddp x) #'oddp #'evenp))

http://www.yqcomputer.com/ ~jeffm/Papers/curry.html

cheers
bobi
 
 
 

Function Application is not Currying

Post by William Ja » Wed, 25 Feb 2009 17:43:51


Clojure:


user=> (defn avg [a b] (/ (+ a b) 2.0))
#'user/avg
user=> (avg 6 7)
6.5
user=> (def avg-with-6 (partial avg 6))
#'user/avg-with-6
user=> (avg-with-6 7)
6.5