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

[solved] pairs of separators from a string

Thread Previous | Thread Next
Marc Chantreux
August 22, 2021 13:20
[solved] pairs of separators from a string
Message ID:
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 seems down at the
> moment)

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

my ($a,$b) = "AaBbCcDd" { .[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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About