[gambit-list] (define ((...) ...)
Bradley Lucier
lucier at math.purdue.edu
Tue Aug 25 20:33:09 EDT 2009
On Aug 25, 2009, at 7:45 PM, Michele Zaffalon wrote:
>
> Hi,
>
> this question has nothing to do with Gambit in particular but I
> couldn't find an explanation.
> In Structure and Interpretation of Classical Mechanics, the *first*
> procedure defined is
>
> (define ((L-free-particle mass) local)
> (let ((v (velocity local)))
> ...)
>
> and the book explains that L-free-particle is a procedure that takes
> mass as an argument and returns a procedure that takes local as a
> parameter.
> Now, what doesn't (define ((L-free-particle mass) local) ... work with
> Gambit? What is missing?
SICM uses an extended "define" form that automatically "curry"s its
definition and is not standard scheme.
Here's a define-macro macro that does what you want.
(define-macro (SICM-define function-name-and-args . body)
(define (curry name-and-args body)
(if (symbol? (car name-and-args))
`(,name-and-args , at body)
(curry (car name-and-args)
`((lambda ,(cdr name-and-args)
, at body)))))
(cons 'define (curry function-name-and-args body)))
(SICM-define (((add-to x) y) z)
(+ x y z))
More information about the Gambit-list
mailing list