Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Scoping question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85677] Scoping question
  • From: Yaroslav Bulatov <yaroslavvb at gmail.com>
  • Date: Tue, 19 Feb 2008 01:54:28 -0500 (EST)

The code below defines a function with parameter x. The body contains
another function definition which uses this parameter. Why do "inner x
is" and "outer x is" lines start reporting different values at one
point?

f1[x_] := (
  f2[y_] := (Print["inner x is ", x]; If[x + 1 < 3, f1[x + 1], 1]);
  (Print["outer x is ", x]; f2[#]) & /@ Range[2];
  )
f1[1]


  • Prev by Date: Re: Helpfile-like action in ordinary notebook
  • Next by Date: No "show labels for the edges" for GraphPlot3D
  • Previous by thread: Re: Summation question
  • Next by thread: Re: Scoping question