my atomicint $c = 0;
sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
say $c;

I was sort of hanging on by my fingertips (this completely lost me:
>Or, taking about tricks:

('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });

) but what's that cabbage thing before $c?  Oh, and WAT is" Weird/will Ass 
Thing"?
________________________________
From: Vadim Belman <vr...@lflat.org>
Sent: Monday, May 24, 2021 8:53 AM
To: perl6-users <perl6-us...@perl.org>
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:


Still ugly but much more reliable trick would be to use a sub and a counter 
variable:

my atomicint $c = 0;
sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
say $c;

Or, taking about tricks:

('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });

Apparently, this one is not ugly by semantics, but by its notation too. Also 
worth noting that the hyper-op is needed here because pointy blocks are not 
auto-threaded over junctions and take them as-is:

-> $v { say $v.WHAT }(1|2); # (Junction)

Best regards,
Vadim Belman

> On May 24, 2021, at 8:42 AM, Daniel Sockwell <dan...@codesections.com> wrote:
>
>> It can be done without the EVAL:
>>
>>> any('a', 'b', 'c').raku.substr(4, *-1).split(',').elems
>>
>> 3
>
> Yeah, but only at the cost of some fragility:
>
>> any('a', 'b,b', 'c').raku.substr(4, *-1).split(',').elems
> 4
>
> I suppose you could do:
>
>> any('a', 'b,b', 'c').elems.raku.substr(4, *-1).split(',').elems
> 3
>
> but I'm not sure that's _that_ much better than EVAL – either way, we're 
> depending on the Str
> representation of inherently non-Str data, which seems like the main sin of 
> EVAL.
>
> – codesections
>

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.

Reply via email to