Re: BEGIN {} question

2022-09-03 Thread ToddAndMargo via perl6-users
On 9/2/22 18:14, ToddAndMargo via perl6-users wrote: On 9/2/22 13:52, ToddAndMargo via perl6-users wrote: On 9/2/22 00:13, ToddAndMargo via perl6-users wrote: Found something interesting $ raku -c GetUpdates.pl6 Syntax OK Will execute the BEGIN {}, not just syntax check it. The guys on the

Re: steps of a path

2022-09-03 Thread Ralph Mellor
Marc Chantreux wrote: > > I got ([^1,^2,^3]) and tried to generalize it with something > more generic (using * to get the number of elements). Yeah, I was disappointed that that didn't work, and that what did was relatively ugly, which is why I didn't bother to share it. <<. raku -ne '.Str.say

Re: steps of a path

2022-09-03 Thread William Michels via perl6-users
Hi Marc, There's also this conversation from March 2021 on the mailing list: https://www.nntp.perl.org/group/perl.perl6.users/2021/03/msg9857.html [Matthew's answer looks very interesting]. Anyway, HTH. --Bill. On Sat, Sep 3, 2022 at 2:51 PM Marc Chantreux wrote: > On Sat, Sep 03, 2022 at

Re: steps of a path

2022-09-03 Thread Marc Chantreux
On Sat, Sep 03, 2022 at 09:50:08PM +0100, Ralph Mellor wrote: > > ( A B C ) to ((A) (A B) (A B C)) ? > [^1,^2,^3] I got that one and tried to generalize it with something more generic (using * to get the number of elements). thanks for helping -- Marc Chantreux Pôle de Calcul et Services

Re: steps of a path

2022-09-03 Thread Marc Chantreux
Hi Bruce and William, Ineed: I was looking for [\,] but your code removes the anoying empty string because of the leading / (which is awesome) so I mixed from both answers (<-[/]> is more robust than .alpha ) and added .Str to .say. finally I got: <<. raku -ne '.Str.say for m:ex /^ ["/"

Re: steps of a path

2022-09-03 Thread Ralph Mellor
On Sat, Sep 3, 2022 at 9:50 PM Ralph Mellor wrote: > > .put for [\~] '/A/B/C' ~~ m:g { '/'? <-[/]>+ } That won't match just a slash (`/`). Maybe: .put for [\~] '/A/B/C' ~~ m:g { ('/'? <-[/]>*) } And it'll treat `/a/b` and `/a/b/` as distinct if the input string is `/a/b/`. -- raiph

Re: steps of a path

2022-09-03 Thread Ralph Mellor
On Sat, Sep 3, 2022 at 9:50 PM Ralph Mellor wrote: > > it makes more sense to do something like Bruce or Michel's solutions. s/Michel/William/ -- raiph

Re: steps of a path

2022-09-03 Thread Ralph Mellor
On Sat, Sep 3, 2022 at 6:17 PM Marc Chantreux wrote: > > ( A B C ) to ((A) (A B) (A B C)) ? [^1,^2,^3] I could share a generalization but it's pretty ugly and I also think it makes more sense to do something like Bruce or Michel's solutions. Here's my variation: .put for [\~] '/A/B/C'

Re: steps of a path

2022-09-03 Thread William Michels via perl6-users
Hi Marc (and Bruce)! Okay, I use our old friend `:exhaustive` adverb below: ~$ echo "/var/log/messages" | raku -ne '.say for m:ex/ ^ ["/" <.alpha>+:]**?{1..*} /;' 「/var」 「/var/log」 「/var/log/messages」 If you remove the `?` frugal quant-modifier, the output is the same--except in the reverse

Re: steps of a path

2022-09-03 Thread Bruce Gray
> On Sep 3, 2022, at 12:17 PM, Marc Chantreux wrote: --snip-- > I thought the raku one could be shorter It will be hard to beat the brevity of a language with single-character instructions. --snip-- > I'm pretty sure I saw a very concise and elegant way to transform > ( A B C ) to ((A) (A

steps of a path

2022-09-03 Thread Marc Chantreux
hello people, I have this steps() function implemented this way in shell: steps() sed -r ':b p; s,/[^/]+$,,; t b' # demo: <<. steps | xargs ls -lUd /var/log/messages which shows -rw-r- 1 root adm 464304 Sep 3 19:03 /var/log/messages drwxr-xr-x 22 root root 4096 Sep 3 00:00 /var/log