[racket] Evaluation problem

From: Thomas Chust (chust at web.de)
Date: Sun Sep 30 17:50:54 EDT 2012

On Mon, 1 Oct 2012, Mikko Tiihonen wrote:

> [...]
> (define make-pair
>  (lambda (first)
>    (lambda (second)
>      (lambda (func)
>        (func first) second))))
> [...]
> So, select-first returns the correct result when applied directly but 
> returns the second argument when applied via make-pair. Also, I have 
> checked that the implementation of make-pair gives the correct result if 
> I do the beta-reduction by hand.
> [...]

Hello Mikko,

the innermost lambda in make-pair consists of two expressions; it applies 
func to first for side effects and then it always returns second.

Probably you wanted to write
   ((func first) second)
instead of
   (func first) second

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1600 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20120930/6eb8e902/attachment.p7s>

Posted on the users mailing list.