Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15618 > unrolled thread
| Started by | Frank Iannarilli <frankeye@cox.net> |
|---|---|
| First post | 2011-02-02 11:08 +0000 |
| Last post | 2011-02-03 10:28 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Frank Iannarilli <frankeye@cox.net> |
|---|---|
| Date | 2011-02-02 11:08 +0000 |
| Subject | Mystifying 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]
| From | Albert Retey <awnl@gmx-topmail.de> |
|---|---|
| Date | 2011-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