in reply to Junction question

Do you mean that you wish to know which element in an any() disjunction has matched in a test (==, >=, etc) or smart match ? Exegesis 6 explains the rules pretty well.

I can't find any documentation that suggests a trace is left of which element in a disjunction has short-circuited (succeeded). Have a look at the source for Perl6::Junction::Any; it's fairly instructive.

Update:

For example:

if $dave == any(1,4,9) { print "I'm sorry, Dave, you're just a square." }

pretty good and concise! But how can I know $dave is equal to which element?

As I said, you probably can't. That's not what it's for.

I guess you're thinking about the disjunction in terms of a captured set of regexp alternatives where you can figure out which alternative matched while accepting any of the alternatives... Junctions don't really work that way; as I suggested, have a look at the Perl6::Junction::Any code.

Also, to understand the concept more generally, take a look at Quantum::Superpositions.

-David

Replies are listed 'Best First'.
Re^2: Juction question
by Anonymous Monk on Oct 31, 2007 at 11:21 UTC
    I guess you're thinking about the disjunction in terms of a captured set of regexp alternatives where you can figure out which alternative matched while accepting any of the alternatives... Junctions don't really work that way; as I suggested, have a look at the Perl6::Junction::Any code. Also, to understand the concept more generally, take a look at Quantum::Superpositions.

    Thanks for your insightful reply! It looks I misunderstood usage of disjunction. Thanks! Researching Quantum seems a good way to understand junction in general.