mit-scheme-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Currying and binding question


From: Taylor R Campbell
Subject: Re: Currying and binding question
Date: Wed, 2 Dec 2020 16:42:38 +0000

> Date: Wed, 2 Dec 2020 11:34:32 -0500
> From: Nicholas Papadonis <nick.papadonis.ml@gmail.com>
> 
> Does function application and variable binding not appear in (pp <>)
> output?  I'm trying to understand why (lambda (c))'s variables are not
> bound.  Thanks
> 
> (define-syntax curry
>   (syntax-rules ()
>     ((_ (a) body ...)
>      (lambda (a) body ...))
>     ((_ (a b ...) body ...)
>      (lambda (a) (curry (b ...) body ...)))))
> 
> ((((curry (a b c) (+ a b c)) 1) 1) 1)
> ;Value: 3
> 
> (pp (((curry (a b c) (+ a b c)) 1) 1))
> (lambda (c)
>   (+ a b c))
> ;Unspecified return value

pp doesn't perform any substitution in the display.  You can see that
it's exactly the same lambda as appears in the text of:

(pp (curry (a b c) (+ a b c)))
(lambda (a)
  (lambda (b)
    (lambda (c)
      (+ a b c))))
;Unspecified return value

You can, however, browse the environment of the closure -- try running
(where (((curry (a b c) (+ a b c)) 1) 1)) and typing `a' to print all
the bindings in the environment.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]