MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Functions, Part 1

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg575] Re: [mg564] Functions, Part 1
  • From: hannibal at caesar.physik.uni-oldenburg.de (L. Hannibal)
  • Date: Mon, 20 Mar 1995 09:59:00 +0100 (NFT)

> 
> 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
> 
> 
Jack,
If x is replaced by 2 in Function[y,y+1], you get Function[y,y+1].
I think what you are looking for is 

h=Function[x,Function[y,y+1][x]]

which does agian what you want.

Yours, Ludger

================================================
Ludger Hannibal
Fachbereich Physik
Carl v. Ossietzky Universitaet Oldenburg
D-26111 Oldenburg, Germany
Phone: +49-441-7983461
Fax: +49-441-7983201
e-mail: hannibal at caesar.physik.uni-oldenburg.de
================================================



  • Prev by Date: Re: Functions, Part 1
  • Next by Date: Re: Functions, Part 1
  • Previous by thread: Re: Functions, Part 1
  • Next by thread: Re: Functions, Part 1