On Fri, Jul 30, 2010 at 2:22 PM, Aaron Sherman wrote:
> If you really want odd, try:
>
> say [1,2,3].first: * === True;
> Result: 1
>
> and
>
> say [5,2,3].first: * === True;
> Result: Rakudo exits silently with no newline
Looks like a side effect of True being implemented as an enum with value
I may be misunderstanding something. I haven't really looked into list
searching much, but there seem to be some very odd and unexpected
results, here.
On Thu, Jul 29, 2010 at 7:52 PM, Jonathan Worthington
wrote:
>> my @x = 1,2,3; say ?...@x.grep(2); say ?...@x.grep(4);
> 1
> 0
>
> Though more e
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:
>
On Thu, Jul 29, 2010 at 7:52 PM, Jonathan Worthington
wrote:
> Note that grep doesn't have to take a closure, but can also take just the
> value you're looking for...
>
>> my @x = 1,2,3; say ?...@x.grep(2); say ?...@x.grep(4);
> 1
> 0
Hm. could have sworn I'd tried that and it didn't work.
> Th
On Thu, Jul 29, 2010 at 4:46 PM, Mark J. Reed wrote:
> $x ~~ any(@array)
I think this came up recently, and that's the way!
-y
Mark J. Reed wrote:
Possibly a FAQ, but is there a simple way of asking if an item is
contained in an array? I know of $x ~~ any(@array) and @array.grep({
$_ ~~ $x}), but those both seem a bit complicated for a conceptually
simple test, so I'm wondering if I'm missing something.
Note that grep d