On Fri, Nov 15, 2002 at 07:05:26AM +1100, Timothy S. Nelson wrote:
> --------------------------------------------------------------
> given ($this) {
> when $that_happens { "Have a party" }
> when $that_doesnt_happen { "Sing" }
> all {
> # Do something
> }
> any {
> # Do something else
> }
> some {
> # Do something other
> }
> none {
> # Do something however
> }
> }
> --------------------------------------------------------------
So, I was all set to show how this could work with junctions, but then
I realized that I don't understand them well enough, so here's what I
came up with:
$j0 = $that_happens | $that_doesnt_happen;
$j1 = !$that_happens | !$that_doesnt_happen;
given ($this) {
when $j0 ~~ $that_happens { ... }
when $j0 ~~ $that_doesnt_happen { ... }
when all($j0) { ... }
when any($j0) { ... }
when any($j1) { ... } # "some" Rare, I expect
when none($j0) { ... }
}
Is that right? Is there a better way? What happens when there's a
junction on either side of a smart match?
> The basic idea is that you have two "special" variables which I will,
> just for now, call $truecount and $falsecount. Basically, every time one of
> the "when" clauses comes up true, it increments truecount; whenever one comes
> up false, it increments $falsecount. The blocks below the given get evaluated
> under the following conditions
>
> all: $falsecount == 0
> any: $truecount > 0
> some: $falsecount > 0
> none: $truecount == 0
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]