# [racket] Evaluation problem

On Sun, 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))))
*
I think you want an extra pair of parens in the line just above:
((func first) second)
Robby
>*
*>* -----
*>>* ((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
*