Re: Functions, Part 1

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg581] Re: [mg564] Functions, Part 1
• From: "Dennis M. Schneider" <dschneid at knox.edu>
• Date: Mon, 20 Mar 1995 16:30:36 -0600 (CST)

```
On Fri, 17 Mar 1995, Jack Goldberg wrote:

> 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
>

In h, body is not a function of x.

In the extreme, if h = Function[x, Function[x,x+1]], since the body is
itself a function and variable declarations are treated as local,
h[anything] will return Function[x,x+1].

Dennis Schneider

```

• Prev by Date: Re: Functions, Part 1
• Next by Date: Re: how to pick out alternating columns and rows in a matrix?
• Previous by thread: Re: Functions, Part 1
• Next by thread: New Book - MATHEMATICA FOR PHYSICS