On Fri, Mar 27, 2009 at 10:39 AM, Dave Whipp <d...@dave.whipp.name> wrote:
> Richard Hainsworth wrote:
>>
>> The following arose out of a discussion on #perl6. Junctions are new and
>> different from anything I have encountered, but I cant get rid of the
>> feeling that there needs to be some more flexibility in their use to make
>> them a common programming tool.
>
> I strongly agree with you, but Larry has repeatedly said that he wants to
> view Junctions as lexical sugar rather than as a powerful programming tool.
> So I'm thinking that we'll need to experiment with modules before anything
> gets admitted to the core language.

Maybe you could have something like a filter function that takes a
junction and a test condition and returns a junction of those
eigenstates from the original one that passed the test.  You could
then handle the Blackjack problem by saying something to the effect
of:

   $p = [+] @p;
   $d = [+] @d;
    if $p <= 21 { # Could the total be 21 or less?
        $p where= { $_ <= 21 } #[ infix:<where> filters the junction
according to the given criteria. ]
        if $p > $d { say "you won!" }
    } else { say "you went over." }

-- 
Jonathan "Dataweaver" Lang

Reply via email to