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 order.

HTH, Bill.

On Sat, Sep 3, 2022 at 12:45 PM Bruce Gray <bruce.g...@acm.org> wrote:

>
> > On Sep 3, 2022, at 12:17 PM, Marc Chantreux <m...@unistra.fr> 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 B) (A B C))
>
> Perhaps you are remembering `produce()`, also called "triangular reduce":
>     https://docs.raku.org/routine/produce
>     https://docs.raku.org/language/operators#Reduction_metaoperators
>
> $ raku -e 'say [\,] <A B C>;'
>     ((A) (A B) (A B C))
>
> $ echo /var/log/messages | raku -ne '.say for [\~] .comb: /\/<-[/]>+/;'
>     /var
>     /var/log
>     /var/log/messages
>
> --
> Hope this helps,
> Bruce Gray (Util of PerlMonks)
>
>

Reply via email to