On Fri, Mar 27, 2009 at 10:27 AM, Moritz Lenz
<ml...@physik.uni-wuerzburg.de> wrote:
> Mark J. Reed wrote:
>> From a high-level perspective, the blackjack example seems perfect for
>> junctions.  An Ace isn't a set of values - its one or the other at a
>> time.  It seems to me if you can't make it work with junctions - f you
>> have to use sets instead - then there's something wrong with the
>> implementation of junctions.
>
> That seems as naiive as saying "regular expressions are for parsing
> text, and if you can't parse XML with regular expressions, there's
> something wrong with them" .

Well, I was being intentionally "naive".  As I said, looking down from
above.  In thinking about examples for explaining junctions, this one
seems a natural fit.

> Leaving aside that Perl 6 regexes do parse XML ;-)

So do Perl 5 ones - since they're not true formal regexes, but have
more power to e.g. match balanced tags.  Plus of course you wouldn't
normally try to write one regex to match an XML document; there'd be
wrapper logic.

Now if you actually parse XML that way, you're being quite silly.
It's far from the best approach.   But while maybe junctions aren't
the best approach to the Blackjack problem, either, it seems less
clear to me.  Maybe that's just because I have less experience with
junctions.

> The answer is that an any()  junction represents just what it says - a 
> conjunction of *any*
> values,not some of the any values. The example would perfectly work if there
> was nothing to filter out. You'd need 'some-of-any' junction here, which
> we don't support.

So at the moment you have to explicitly extract the eigenstates you're
interested in, and then construct new junctions from them. Something
like this:

some($d) < 21 && some($p) < 21 && any(grep { $_ < 21 }
$d.eigenstates}) > all(grep { $_ < 21 } $p.eigenstates)

But it still seems that junctions let you do this more cleanly than
sets.  Or maybe P6 Sets are more powerful than I think?  Given two
junctions $d and $p, just adding $d + $p gives you all the possible
sums of the eigenstates.  Given two sets D and P, is there an equally
simple op to generate { d + p : d ∈ D, p ∈ } ?

-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to