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

MathGroup Archive 2011

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

Search the Archive

Re: Mystifying Scoping of Piecewise Variable?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116125] Re: Mystifying Scoping of Piecewise Variable?
  • From: Tomas Garza <tgarza10 at msn.com>
  • Date: Thu, 3 Feb 2011 05:27:27 -0500 (EST)

Shouldn't the argument of myFunc in the definition be x_?
-Tomas

> Date: Wed, 2 Feb 2011 06:08:08 -0500
> From: frankeye at cox.net
> Subject: [mg116102] Mystifying Scoping of Piecewise Variable?
> To: mathgroup at smc.vnet.net
>
> Perhaps I'm tired, but this is weird:
>
> Clear[myFunc]
>
> myFunc[y_] = Piecewise[{{x^2, x < 0}, {x, x >= 0}}]
>    (Same behavior below for either Set(=) or SetDelayed(:=) )
>
> Plot[myFunc[y], {y, -10, 10}]
>   (returns empty plot)
>
> Plot[myFunc[x], {x, -10, 10}]
>   (returns "expected" piecewise function plot)
>
> What is the scoping of the Piecewise variable, in this case "x"? 
>
> How can one write a Module that creates and returns a Piecewise function? The scope of its argument is unclear to me.
>
> Thanks


  • Prev by Date: Re: Mystifying Scoping of Piecewise Variable?
  • Next by Date: Re: Mystifying Scoping of Piecewise Variable?
  • Previous by thread: Re: Mystifying Scoping of Piecewise Variable?
  • Next by thread: Re: Mystifying Scoping of Piecewise Variable?