nested function calls

92 views
Skip to first unread message

jonazza...@gmail.com

unread,
Mar 7, 2014, 1:12:55 PM3/7/14
to proglang-c...@googlegroups.com
Hi

How should we evaluate :

id x = x;
twice f x = f (f x) ;
main = twice id 6  ;

in good1.fun

as it requires another function?



Aarne Ranta

unread,
Mar 8, 2014, 11:48:38 AM3/8/14
to proglang-c...@googlegroups.com
Hello,

Can you explain what you mean by "requires another function"? Everything that is needed is in the code.

The evaluation should go this way:

  main
  = twice id 6
  = (\f -> \x -> f (f x)) id 6
  = id (id 6)
  = (\x -> x) (id 6)
  = id 6
  = (\x -> x) 6
  = 6

Not necessarily in this order, but these are the main steps and the result.

Regards

  Aarne. 
Reply all
Reply to author
Forward
0 new messages