On May 27, 2009, at 3:21 AM, Eduardo Cavazos wrote:

I have a feeling the above can be simpler...

Abdulaziz Ghuloum wrote:

(define-syntax curry
  (syntax-rules ()
    [(_ proc x) (lambda (x) (proc x))]
    [(_ proc x x* ...)
     (lambda (x)
       (curry (lambda (x* ...) (proc x x* ...)) x* ...))]))

What about:

(define-syntax curry
  (syntax-rules ()
    [(_ proc x) proc]
    [(_ proc x x* ...)
     (lambda (x)
       (curry (lambda (x* ...) (proc x x* ...)) x* ...))]))

I.e. the first clause is simplified. Seems to work. So maybe *this* is the one from The Book. :-)

Ed

Reply via email to