Patrick R. Michaud wrote:
On Wed, Apr 27, 2005 at 08:46:53AM -0400, Joshua Gatcomb wrote:

The problem is that in the regex version I use capturing parens to
identify the character matched.  For the purposes of the problem I
don't need to rely on the first character matched I just need to know
1.

Without doing a lot of research into junctions, I thought the
following would work:

my $matches = any( @x_chars ) eq any( @y_chars );
my $match = $matches.pick;


Perhaps the easiest way to explain the difficulty here is to note that
executing a relational op (i.e. returning a boolean) value on a junction
argument returns a junction of boolean values.

Is that so? Does Perl6 have some fundamental law of junction preservation? I would expect $matches to be either false or true---the junction values are garbage collected.


...  or if it could "pick" one of the empty
string values.

That's my understanding. The junctive value is lazily evaluating the list of all permutations from @x_chars and @y_chars one at a time. The myeq is called once for .pick and the result goes into $match.

But if you could use 'permute( @x_chars ) »myeq« permute( @y_chars )'
after writing the permute function ;)

And I wonder if

permute( @x_chars ) »{ $^a eq $^b ?? $^a :: ''}« permute( @y_chars )

would do the same?
--
TSa (Thomas Sandlaß)




Reply via email to