develooper Front page | perl.perl6.language | Postings from April 2005

Malfunction Junction, what's your function?

Thread Next
Joshua Gatcomb
April 27, 2005 05:47
Malfunction Junction, what's your function?
Message ID:
Ok - sorry for the cheesy subject line but I couldn't resist.

So I am working on porting some interesting pieces of code I wrote in
p5 at the Monastery to p6 for the benefit of others - primarily to
show how easy the transition can be.

Since Pugs doesn't have p6 rules yet I wanted to show off the power of
junctions instead of using the pcre support.  Basically I need to know
if any character in string x matches any character in string y - easy
right:  $str =~ /[chars]/ becomes any( @x_chars ) eq any( @y_chars ). 
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

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;

Ok - so maybe not - perhaps I should just change .pick to .values

hmmm - still not working - perhaps I need to give the junctions more
information as to what I am after

all( any() eq any() );

Hmmm - perhaps the problem isn't with junctions but with Pugs but to
know for sure I need to find out what, if anything, is the proper way
to do what I want.  The worst that could happen is that I find out
there isn't a way to get a what matched from an any() eq any()

Joshua Gatcomb
a.k.a. L~R

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About