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

(sigils are awesome, they say ...) Re: pairs of separators from astring

Thread Previous | Thread Next
From:
Marc Chantreux
Date:
August 22, 2021 12:58
Subject:
(sigils are awesome, they say ...) Re: pairs of separators from astring
Message ID:
YSJJ0PtmhEPTAotv@prometheus.u-strasbg.fr
thanks everyone for sharing,

Vadim,

my ($a, $b) = { @^a[0,2...Inf], @a[1,3...Inf] }.(q<(){}[]>.comb); say $a[0]; say $b[0]

oh. i never see this direct call of a lambda before but it really makes
sense! this is the answer i like the most.

i rewrote it my way and this works

my ($a, $b) = { .[0,2…∞], .[1,3…∞] }.(q<AABBCCDD>.comb);

it would be nice if this one will:

my ($a, $b) = { .[0,2…∞], .[1,3…∞] }.: q<AABBCCDD>.comb;

But here is one of the reasons i'm still unconfortable with raku is the
fact that sigils don't make sense anymore to me (in the contrary of perl
were sigils means "i want a [$%@] from this").

so as i can't get grid of sigils in this case

    my (\a, \b) = { .[0,2…∞], .[1,3…∞] }.(q<AABBCCDD>.comb);

i need to choose a sigil. The way i understand sigils is
"an optional type specifier". to me

    my $truc  => my container 'truc' for anything you want
    my @truc  => my container 'truc' for something that should mostly
                 be understood as indexed
    my %truc  => my container 'truc' for something that should mostly
                 be understood as associative

so of course i tried

my (@a, @b) = { .[0,2…∞], .[1,3…∞] }.(q<AABBCCDD>.comb);

because i have two lists and two containers. this doesn't work.
which means @ and $ combines with = to define how things are stored
but i don't understand how for the moment.

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