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?
Thanks, michele
Afficher les réponses par date
Michele Zaffalon wrote:
Now, what doesn't (define ((L-free-particle mass) local) ... work with Gambit? What is missing?
You can create a new version of 'define' which behaves that way:
(define-syntax define* (syntax-rules () ((_ ((x . f1) . f2) . b) (define* (x . f1) (lambda f2 . b))) ((_ . r) (define . r))))
The SICM text should have an explanation of this particular notation.
Thanks to Derick Eddington for the definition.
Ed
I suppose I have to start Gambit with gsi -:s. Still it doesn't work: invalid syntax.
On Tue, Aug 25, 2009 at 7:50 PM, Eduardo Cavazoswayo.cavazos@gmail.com wrote:
Michele Zaffalon wrote:
Now, what doesn't (define ((L-free-particle mass) local) ... work with Gambit? What is missing?
You can create a new version of 'define' which behaves that way:
(define-syntax define* (syntax-rules () ((_ ((x . f1) . f2) . b) (define* (x . f1) (lambda f2 . b))) ((_ . r) (define . r))))
The SICM text should have an explanation of this particular notation.
Thanks to Derick Eddington for the definition.
Ed _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Try the following, which does not require define-syntax:
(define-macro (define pattern . rest) (if (pair? pattern) `(define ,(car pattern) (##lambda ,(cdr pattern) ,@rest)) `(##define ,pattern ,@rest)))
(define (((f x) y) z) (+ x y z))
(define g (f 1)) (define h (g 2)) (pp (h 10))
Marc
On 25-Aug-09, at 8:32 PM, Michele Zaffalon wrote:
I suppose I have to start Gambit with gsi -:s. Still it doesn't work: invalid syntax.
On Tue, Aug 25, 2009 at 7:50 PM, Eduardo Cavazos<wayo.cavazos@gmail.com
wrote: Michele Zaffalon wrote:
Now, what doesn't (define ((L-free-particle mass) local) ... work with Gambit? What is missing?
You can create a new version of 'define' which behaves that way:
(define-syntax define* (syntax-rules () ((_ ((x . f1) . f2) . b) (define* (x . f1) (lambda f2 . b))) ((_ . r) (define . r))))
The SICM text should have an explanation of this particular notation.
Thanks to Derick Eddington for the definition.
Ed _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On Tue, Aug 25, 2009 at 8:36 PM, Marc Feeleyfeeley@iro.umontreal.ca wrote:
Try the following, which does not require define-syntax:
(define-macro (define pattern . rest) (if (pair? pattern) `(define ,(car pattern) (##lambda ,(cdr pattern) ,@rest)) `(##define ,pattern ,@rest)))
(define (((f x) y) z) (+ x y z))
(define g (f 1)) (define h (g 2)) (pp (h 10))
Marc
Thanks. michele
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 ,@body) (curry (car name-and-args) `((lambda ,(cdr name-and-args) ,@body)))))
(cons 'define (curry function-name-and-args body)))
(SICM-define (((add-to x) y) z) (+ x y z))