Functions, Part 1
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg564] Functions, Part 1
- From: Jack Goldberg <Jack.Goldberg at math.lsa.umich.edu>
- Date: Fri, 17 Mar 1995 10:04:44 -0500 (EST)
Hi mathgroup: In trying to understand all the differences between f[] and Function[] I ran across something which puzzles me. Consider the following: (1) f[x_] := x + 1 (2) g = Function[x,f[x]] (3) h = Function[x,Function[y,y+1]] Now g[2] and f[2] output 3 as expected. But h[2] (indeed, h[garbage]) outputs Function[y,y+1]. What`s going on? Clearly, I do not understand exactly what happens when one uses the notation Function[x,body][2] since what I thought happens was this: Every appearance of x in the expression "body" is replaced by 2 and then body is evaluated. In view of (3) this surely is not what happens. Or am I way off base? Jack