Re: Ex4 smart match question

2002-04-08 Thread Piers Cawley
Damian Conway <[EMAIL PROTECTED]> writes: > Incidentally, the table of C<=~> comparisons (Table 1) at: > > http://dev.perl.org/perl6/apocalypse/4 > > suggests that hash/hash matching is equivalent to: > > match if grep exists $a{$_}, $b.keys > > I hope to convince Larry that it would b

Re: Ex4 smart match question

2002-04-07 Thread Damian Conway
Peter Scott asked: > Why give up the chance to let things that look different behave differently? Because then you'd have to remember which order did what. Forcing you to actually think and remember is very unDWIMical. ;-) > What do [the following do]? > > @left =~ @right Array int

Re: Ex4 smart match question

2002-04-06 Thread Peter Scott
At 10:34 AM 4/7/02 +1000, Damian Conway wrote: > > It's very cool--but why is it $key =~ %hash but $value =~ @array rather > > than one way or the other? > >Because it's *both* ways. Perl 6's C<=~> operator is reversible. > >So you can write: > > $key =~ %hash > >or: > > %hash =~ $

Re: Ex4 smart match question

2002-04-06 Thread Damian Conway
John A asked: > > This new turbo-charged 'smart match' operator will also work on arrays, > > hashes, and lists: > It's very cool--but why is it $key =~ %hash but $value =~ @array rather > than one way or the other? Because it's *both* ways. Perl 6's C<=~> operator is reversible. So you can

Re: Ex4 smart match question

2002-04-05 Thread Luke Palmer
On Fri, 5 Apr 2002 [EMAIL PROTECTED] wrote: > Does one of these items not belong? > > >From Exegesis 4: > > This new turbo-charged 'smart match' operator will also work on arrays, hashes and >lists: > > > if @array =~ $elem {...}# true if @array contains $elem > > if $ke

Ex4 smart match question

2002-04-05 Thread jadams01
Does one of these items not belong? >From Exegesis 4: This new turbo-charged 'smart match' operator will also work on arrays, hashes and lists: if @array =~ $elem {...}# true if @array contains $elem if $key =~ %hash {...} # true if %hash{$key} if $value