About fst (twice (\x -> x)) 6 7 ; -- result 7

2 views
Skip to first unread message

Arnar Birgisson

unread,
Mar 3, 2010, 10:13:41 AM3/3/10
to proglang-c...@googlegroups.com
Hej,

Someone asked about this test code from lab 4 in the lab session today:

twice f x = f (f x) ;
fst x y = x ;

main = fst (twice (\x -> x)) 6 7 ; -- result 7


Tracing it on paper, we found out that the result would be 6, but 7 is
indeed the correct one with the parentheses set as above.

The evaluation should be something like:
fst (twice (\x -> x)) 6 7 <- here fst is applied on the function and 6
(twice (\x -> x)) 7
(\x -> x) ((\x -> x) 7)
(\x -> x) 7
7

cheers,
Arnar

Reply all
Reply to author
Forward
0 new messages