Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15618 > unrolled thread

Mystifying Scoping of Piecewise Variable?

Started byFrank Iannarilli <frankeye@cox.net>
First post2011-02-02 11:08 +0000
Last post2011-02-03 10:28 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Mystifying Scoping of Piecewise Variable? Frank Iannarilli <frankeye@cox.net> - 2011-02-02 11:08 +0000
    Re: Mystifying Scoping of Piecewise Variable? Albert Retey <awnl@gmx-topmail.de> - 2011-02-03 10:28 +0000

#15618 — Mystifying Scoping of Piecewise Variable?

FromFrank Iannarilli <frankeye@cox.net>
Date2011-02-02 11:08 +0000
SubjectMystifying Scoping of Piecewise Variable?
Message-ID<iibduv$npg$1@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

[toc] | [next] | [standalone]


#15736

FromAlbert Retey <awnl@gmx-topmail.de>
Date2011-02-03 10:28 +0000
Message-ID<iidvvl$bia$1@smc.vnet.net>
In reply to#15618
Hi,

> 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(:=) )
>

It is just that you use y on the LHS but x on the RHS...
Oh yes, I guess you were tired :-)...

hth,

albert

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web