Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: Functions, Part 1

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg572] Re: [mg564] Functions, Part 1
  • From: twj (Tom Wickham-Jones)
  • Date: Sun, 19 Mar 1995 10:19:57 -0600


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

This is exactly correct.  


What you should have done for 3) is

In[4]:= h = Function[x,Function[y,y+1][x]]

Out[4]= Function[x, Function[y, y + 1][x]]

In[5]:= h[2]

Out[5]= 3

The way the argument gets into the nested function which
is what you want.



Tom Wickham-Jones
WRI





  • Prev by Date: Re: (-1)^(3/4) -> (-1+I)/Sqrt[2]
  • Next by Date: Re: Functions, Part 1
  • Previous by thread: Functions, Part 1
  • Next by thread: Re: Functions, Part 1