MathGroup Archive 2008

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

Search the Archive

Scoping question

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

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

  • 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