Re: File::Find using a junction with exclude

2021-06-01 Thread Ralph Mellor
On Fri, May 21, 2021 at 4:36 PM Ralph Mellor wrote: > > * Things multiply. If *two* function arguments are junctions, and > each junction has, say, three elements, the function is set to be > called *six* times. That should have been *nine* times. > * The combination has to follow precedence

Re: File::Find using a junction with exclude

2021-05-25 Thread Andy Bach
t: Tuesday, May 25, 2021 4:04 PM To: perl6-users@perl.org Subject: Re: File::Find using a junction with exclude CAUTION - EXTERNAL: Well spotted, Gianni! user@mbook:~$ raku -e 'my int $x = 2โถยณ-1;say ++$x;' -9223372036854775808 user@mbook:~$ raku --version Welcome to ๐‘๐š๐ค๐ฎ๐๐จโ„ข v2020.10

Re: File::Find using a junction with exclude

2021-05-25 Thread William Michels via perl6-users
Well spotted, Gianni! user@mbook:~$ raku -e 'my int $x = 2โถยณ-1;say ++$x;' -9223372036854775808 user@mbook:~$ raku --version Welcome to ๐‘๐š๐ค๐ฎ๐๐จโ„ข v2020.10. Implementing the ๐‘๐š๐ค๐ฎโ„ข programming language v6.d. Built on MoarVM version 2020.10. On Tue, May 25, 2021 at 8:38 AM Gianni Ceccarelli wrote: >

Re: File::Find using a junction with exclude

2021-05-25 Thread Gianni Ceccarelli
On Tue, 25 May 2021 15:16:03 + Andy Bach wrote: > > However I had to use "Int" instead of "int": > Ah, "int" is the "lower" level, native integer and "Int" is the raku. > An "int" is immutable or something? It's a bug in the REPL. The example from the documentation works when fed to the comp

Re: File::Find using a junction with exclude

2021-05-25 Thread Andy Bach
_______ From: William Michels Sent: Monday, May 24, 2021 11:47 PM To: perl6-users Subject: Re: File::Find using a junction with exclude CAUTION - EXTERNAL: Hi Andy, A quick test with my (older) Raku install and I was able to get one of the examples (Daniel's) below

Re: File::Find using a junction with exclude

2021-05-24 Thread William Michels via perl6-users
$) { ++$d }('a'|'b,b'|'c'); > Cannot find method 'qast' on object of type NQPMu > > > my int $f = 0; > 0 > > sub foo($) { ++$f }('a' | 'b,b' | 'c'); > Cannot find method 'qast' on object o

Re: File::Find using a junction with exclude

2021-05-24 Thread William Michels via perl6-users
Apologies, that should be spelled "intriguing". --B. On Mon, May 24, 2021 at 12:41 PM William Michels wrote: > WATs are everywhere, and (I'm not trying to pick on one language > here), I find this SO question to be intruiging: > > https://stackoverflow.com/q/58340585/7270649 > > Joseph (and Ral

Re: File::Find using a junction with exclude

2021-05-24 Thread Andy Bach
'b,b' | 'c'); Cannot find method 'qast' on object of type NQPMu but my raku's a tad long in tooth $ raku -v This is Rakudo version 2020.05.1 built on MoarVM version 2020.05 ________ From: William Michels Sent: Monday, May 24, 2021 2:41

Re: File::Find using a junction with exclude

2021-05-24 Thread Gianni Ceccarelli
On 2021-05-24 William Michels via perl6-users wrote: > Daniel: Thank you for your confirmation on EVAL. Also, I tried parsing > the ATOM SYMBOL character to look at classification, and this is the > best I could do (in the Raku REPL): > > > say "โš›".uniprop > So Not-terribly-human-friendly abbrev

Re: File::Find using a junction with exclude

2021-05-24 Thread William Michels via perl6-users
WATs are everywhere, and (I'm not trying to pick on one language here), I find this SO question to be intruiging: https://stackoverflow.com/q/58340585/7270649 Joseph (and Ralph): thanks for starting off this conversation! Fernando and Vadim: amazed at your code! Andy: good questions always welcom

Re: File::Find using a junction with exclude

2021-05-24 Thread Daniel Sockwell
> Oh, and WAT is [short for] "Weird/will Ass Thing"? No, it's not an abbreviation for anything โ€“ it's the word "what", but pronounced in a way that indicates the speaker is surprised/confused. More specifically, it's a reference to the WAT talk (a really good one, even if it is about a different

Re: File::Find using a junction with exclude

2021-05-24 Thread Andy Bach
'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"? __

Re: File::Find using a junction with exclude

2021-05-24 Thread Daniel Sockwell
'); > 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 i

Re: File::Find using a junction with exclude

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

Re: File::Find using a junction with exclude

2021-05-24 Thread Andy Bach
#x27;s that cabbage thing before $c? Oh, and WAT is" Weird/will Ass Thing"? From: Vadim Belman Sent: Monday, May 24, 2021 8:53 AM To: perl6-users Subject: Re: File::Find using a junction with exclude CAUTION - EXTERNAL: Still ugly but much more reliable trick

Re: File::Find using a junction with exclude

2021-05-24 Thread Vadim Belman
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. A

Re: File::Find using a junction with exclude

2021-05-24 Thread Daniel Sockwell
> 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(',')

Re: File::Find using a junction with exclude

2021-05-24 Thread Fernando Santagata
It can be done without the EVAL: > any('a', 'b', 'c').raku.substr(4, *-1).split(',').elems 3 On Mon, May 24, 2021 at 1:07 PM Daniel Sockwell wrote: > > But .EVAL is evil, right? > > Indeed! And > any('a', 'b', 'c').raku.substr(3).EVAL.elems; > arguably deserves _extra_ evil points for usin

Re: File::Find using a junction with exclude

2021-05-24 Thread Daniel Sockwell
> But .EVAL is evil, right? Indeed! And any('a', 'b', 'c').raku.substr(3).EVAL.elems; arguably deserves _extra_ evil points for using the .EVAL method which, unlike the EVAL sub, doesn't even warn about how dangerous it is (even though it probably should).

Re: File::Find using a junction with exclude

2021-05-24 Thread William Michels via perl6-users
But .EVAL is evil, right? --B. On Sun, May 23, 2021 at 9:38 PM Daniel Sockwell wrote: > > > For example, you can't get a count of the number of elements in a junction > > Well, if you're willing to stoop to ugly enough hacks, there's _always_ a > way :D > > any('a', 'b').raku.substr(3).EVAL.elem

Re: File::Find using a junction with exclude

2021-05-23 Thread Daniel Sockwell
> For example, you can't get a count of the number of elements in a junction Well, if you're willing to stoop to ugly enough hacks, there's _always_ a way :D any('a', 'b').raku.substr(3).EVAL.elems # OUTPUT ยซ3ยป > My guess would be that the `ACCEPTS` method for a Junction is special cased to ha

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 9:15 PM Joseph Brenner wrote: > > Junctions continue to surprise me: That must be either that your mental model doesn't match the default design, or you're being tripped up by DWIMs, or WATs that can't be removed due to the overall DWIM of junctions (which usually work gre

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 9:12 PM Joseph Brenner wrote: > > my impression was that junctions, by design aren't supposed to be > treated as compound data structures, they're a *single* thing but > with multiple values that co-exist with each other in "superposition". That's correct. Until they're e

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 3:22 AM Joseph Brenner wrote: > > > That is a large part of the beauty of the junction design. All functions > > (and thus all operators) automatically get a very useful and powerful > > junctional behavior for free. They don't even know junctions exist. > > I can see the p

Re: File::Find using a junction with exclude

2021-05-23 Thread Vadim Belman
You're wrong in your expectations. Smartmatch as such is implemented by ACCEPTS method of its RHS. It is Junction.ACCEPTS in our case. Unfortunately, the method is not documented for Junction, but it considers itself a boolean context and, correspondingly, collapses the junction. Not it is tr

Re: File::Find using a junction with exclude

2021-05-23 Thread Vadim Belman
This: $junction>>.say; works the way it is because the junction is passed as an argument to the hyper operator where the normal rules apply. Try it this way: say $junction>>.say; and it will result in: a b c any((True), (True), (True)) Best regards, Vadim Belman > On May 23, 2021, at 4:12 P

Re: File::Find using a junction with exclude

2021-05-23 Thread Joseph Brenner
Junctions continue to surprise me: my $junction = any( 'a', 'b', 'c' ); my $char = 'b'; say $char ~~ $junction; # True say $char eq $junction; # any(False, True, False) $char = 'e'; say $char ~~ $junction; # False say $char eq $junction; # any(False, False, False) I w

Re: File::Find using a junction with exclude

2021-05-23 Thread Joseph Brenner
William Michels wrote: > my $exclude3 = ( rx/<|w>mothera$/, rx/<|w>camel$/ ); > my @files3 = find( dir => $loc, type => 'file', exclude => $exclude3>>.any > ); > say "Exclude3: ", @files3; > #Exclude3: ["/Users/me/test_folder/.DS_Store".IO > "/Users/me/test_folder/godzilla".IO "/Users/me/test_fol

Re: File::Find using a junction with exclude

2021-05-22 Thread Joseph Brenner
Ralph Mellor wrote: > A junction passed as an argument is immediately expanded unless > a function is specifically coded to handle junctions for that argument. > > That is a large part of the beauty of the junction design. All functions > (and thus all operators) automatically get a very useful a

Re: File::Find using a junction with exclude

2021-05-22 Thread Joseph Brenner
Vadim Belman wrote: >> Joseph Brenner wrote: >> >>> I just gave a few other variants a try-- passing a junction in a >> variable, passing a code block containing a [junction]-- without any >> luck. > To my view, this behavior of File::Find is going against DWIM and is > certainly LTA. Thanks,

Re: File::Find using a junction with exclude

2021-05-21 Thread Ralph Mellor
On Fri, May 21, 2021 at 9:39 PM Joseph Brenner wrote: > > Thanks, yes the actual result is certainly consistent with the > junction applied at the top level, and not internally, which is > what I was expecting. A junction passed as an argument is immediately expanded unless a function is specific

Re: File::Find using a junction with exclude

2021-05-21 Thread William Michels via perl6-users
I tried this--from your original file, not your most recent attempt--and couldn't get it to work. If you look below, "mothera" never gets excluded, except the last test (Exclude4), which is the control case (single regex, no any junction): my @exclude1 = ( rx/<|w>mothera$/, rx/<|w>camel$/ ); my @f

Re: File::Find using a junction with exclude

2021-05-21 Thread Vadim Belman
To my view, this behavior of File::Find is going against DWIM and is certainly LTA. Anyway, what you you probably is looking for is something like exclude => { $_ ~~ any(@exclude) } BTW, the only thing File::Find needs to work with junctions is to declare :$exclude as Mu. In this case the cal

Re: File::Find using a junction with exclude

2021-05-21 Thread Joseph Brenner
> I just gave a few other variants a try-- passing a junction in a variable, passing a code block containing a function-- without any luck. Sorry, I mean a code block containing a *junction* or course. Like: my @exclude = ( rx/<|w>mothera$/, rx/<|w>camel$/ ); my $any_exclude = any(@e

Re: File::Find using a junction with exclude

2021-05-21 Thread Joseph Brenner
Thanks, yes the actual result is certainly consistent with the junction applied at the top level, and not internally, which is what I was expecting. Is there actually no way to pass a junction in to a function so that it can be used later in an internal smartmach? That's been my rough impression

Re: File::Find using a junction with exclude

2021-05-21 Thread Ralph Mellor
Your results are what I would expect. The hand crafted regex puts the exclusion logic in the *single* regex that's applied by the *single* call to the `find` function. The `any` value results in calling the `find` function *twice*, with 'mothera' excluded one time, and 'camel' excluded the second

File::Find using a junction with exclude

2021-05-20 Thread Joseph Brenner
The documentation for File::Find says that the exclude argument is applied via a smart-match, so I thought that I could use a junction, like so: use File::Find my @files = find( dir => $loc, type => 'file', exclude => any( @exclude_pats ) ); But instead of getting an array of file names (ei