On Fri, Jul 30, 2010 at 01:52:18AM +0200, Jonathan Worthington wrote:
> Mark J. Reed wrote:
> >Possibly a FAQ, but is there a simple way of asking if an item is
> >contained in an array?  
> 
> > my @x = 1,2,3; say ?...@x.grep(2); say ?...@x.grep(4);
> 1
> 0
> 
> Though more efficient would be:
> 
> > my @x = 1,2,3; say ?...@x.first(2); say ?...@x.first(4);
> 1
> 0

If .grep and List.Bool are implemented the way I think they should
be (and the way they are in Rakudo), then both of the above are 
equally efficient.  :-)

Pm

Reply via email to