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
dr
> 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
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 ord
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' ~
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
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
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 /^ ["/" <-[/]>+:
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 Av
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 09
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 f
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
11 matches
Mail list logo