# [racket] Evaluation problem

 From: Mikko Tiihonen (mikko.tiihonen at tmtiihonen.fi) Date: Mon Oct 1 00:52:38 EDT 2012 Next message: [racket] Racket gui Messages sorted by: [date] [thread] [subject] [author]

```Hi, Jim, Robby and Thomas!

Problem solved - case of "late night eyes" after all :) Thank you!

Best,

Mikko

On 1.10.2012, at 1:01, Jim Bender wrote:

> You are missing a pair of parens around '(func first)' and 'second'. The current code in your message will return second, no matter what function you pass in as 'func'.
>
> The correct definition for make-pair should be:
>
>> define make-pair
>> (lambda (first)
>>   (lambda (second)
>>     (lambda (func)
>>       ((func first) second)))))
>
>
> Jim
>
> On Sep 30, 2012, at 4:43 PM, Mikko Tiihonen <mikko.tiihonen at tmtiihonen.fi> wrote:
>
>> Hi!
>>
>> I have been going through some lambda-calculus exercises with Racket. I have stumbled on a puzzling problem where beta-reduction by hand leads  to different result from that generated by Racket.
>>
>>
>> (define select-first
>> (lambda (first)
>>   (lambda (second)
>>     first)))
>>
>> (define select-second
>> (lambda (first)
>>   (lambda (second)
>>     second)))
>>
>> (define make-pair
>> (lambda (first)
>>   (lambda (second)
>>     (lambda (func)
>>       (func first) second))))
>>
>> -----
>>> ((select-first 'a) 'b)
>> 'a
>>> ((select-second 'a) 'b)
>> 'b
>>> (((make-pair 'a) 'b) select-first)
>> 'b
>>> (((make-pair 'a) 'b) select-second)
>> 'b
>> -------
>>
>> 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.
>>
>> I suspect that I'm missing something obvious, but I really cannot find the reason why make-pair misbehaves - you gurus on this mailing-list probably can pinpoint the problem instantly :)
>>
>> Best regards,
>>
>> -Mikko Tiihonen
>>
>> P.S.  Having used Racket for some months now, I find both Racket and the community around it really great!
>>
>>
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121001/f2f24a04/attachment-0001.html>
```

 Posted on the users mailing list. Next message: [racket] Racket gui Messages sorted by: [date] [thread] [subject] [author]