develooper Front page | perl.perl6.users | Postings from August 2021

[solved] pairs of separators from a string

Thread Previous | Thread Next
From:
Marc Chantreux
Date:
August 22, 2021 13:20
Subject:
[solved] pairs of separators from a string
Message ID:
YSJPJKuBzDWNATH3@prometheus.u-strasbg.fr
hello Yary,

> and my instinct is that "map" is adding a layer you don't need or want for
> this issue, should just be sending the results of comb to a block. But I
> can't quite get the syntax right (and docs.raku.org seems down at the
> moment)

With this and what i understood from Vladim, i tried this

my ($a,$b) = "AaBbCcDd".comb.map: { .[0,2…*], .[1,3…*] };
say $a;

it failed too. Also: the Vladim example of a direct call of the lambda
seems intellectually closer to the problem to me. i realized that the
perl map and for with scalars are work arounds. raku has with.

so i tried:

my ($a,$b) = .[0,2…*], .[1,3…*] with "AaBbCcDd".comb;
say $a

which is exactly the way i want to write things :)

> I sent a variation of this as a potential question to Perl Weekly
> Challenge, maybe it will get a bunch of answers in a few weeks!

i'll be happy to read other answers.

regards.
marc

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About