Re: Malfunction Junction, what's your function?

2005-04-28 Thread Thomas Sandlaß
I wrote: permute( @x_chars ) »{ $^a eq $^b ?? $^a :: ''}« permute( @y_chars ) Permutation is the wrong thing here, sorry. It's just: ( @x_chars »xx« @y_chars.elems ) # or was that .size? »{ $^a eq $^b ?? $^a :: ''}« ( @y_chars xx @x_chars.elems ) # note: no hypering e.g. a b c and x y give a

Re: Malfunction Junction, what's your function?

2005-04-28 Thread Joshua Gatcomb
On 4/28/05, Thomas Sandlaß [EMAIL PROTECTED] wrote: I wrote: permute( @x_chars ) »{ $^a eq $^b ?? $^a :: ''}« permute( @y_chars ) Permutation is the wrong thing here, sorry. It's just: I want to preface again that I have only recently started giving the language aspect of p6 serious focus.

Re: Malfunction Junction, what's your function?

2005-04-28 Thread Thomas Sandlaß
Joshua Gatcomb wrote: ... FAQs such as union, difference, intersection of lists are FAQs for a reason. ... it would be nice to have a real simple easy answer for p6. And indeed it could be: use Sets; my @a is Set = (1,2,3); my @b is Set = (2,3,4); say @a + @b; # (1,2,3,4) say @a / @b; # (2,3)

Malfunction Junction, what's your function?

2005-04-27 Thread Joshua Gatcomb
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

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Patrick R. Michaud
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

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Thomas Sandlaß
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.

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Paul Seamons
Minor note. Would you want this: sub infix:myeq(Str $a, Str $b) { return ($a eq $b) ? $a : ''; } to be: sub infix:myeq(Str $a, Str $b) { return ($a eq $b) ? $a but bool::true: ''; } (Is that the right way to do it ?) Paul

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Jonathan Scott Duff
On Wed, Apr 27, 2005 at 10:30:35AM -0600, Paul Seamons wrote: Minor note. Would you want this: sub infix:myeq(Str $a, Str $b) { return ($a eq $b) ? $a : ''; } to be: sub infix:myeq(Str $a, Str $b) { return ($a eq $b) ? $a but bool::true: ''; } (Is that the right way to do

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Luke Palmer
Thomas Sandla writes: 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

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Patrick R. Michaud
On Wed, Apr 27, 2005 at 06:29:46PM +0200, Thomas Sandlaß wrote: Patrick R. Michaud wrote: 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)

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Rod Adams
Thomas Sandlaß wrote: 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

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Patrick R. Michaud
On Wed, Apr 27, 2005 at 10:30:35AM -0600, Paul Seamons wrote: Minor note. Would you want this: sub infix:myeq(Str $a, Str $b) { return ($a eq $b) ? $a : ''; } to be [corrected]: sub infix:myeq(Str $a, Str $b) { return ($a eq $b) ?? $a but bool::true :: ''; } Perhaps, but I

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Luke Palmer
Rod Adams writes: 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

Re: Malfunction Junction, what's your function?

2005-04-27 Thread Rod Adams
Luke Palmer wrote: Rod Adams writes: 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