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

2021-08-23 Thread yary
A little more of Vadim's example > my $a = ; say $a.raku; ("a", "b", "c") > my @a = ; say @a.raku; ["a", "b", "c"] > @a[1]='X'; say @a.raku; ["a", "X", "c"] > $a[1]='X' Cannot modify an immutable List ((a b c)) in block at line 1 $a is a scalar container, holds one thing. In this example a Li

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

2021-08-22 Thread Vadim Belman
Sigils mean a lot. For example, they create a context: my $a = 1,2,3; my @a = 1,2,3; $a = ; say $a.raku; @a = ; say @a.raku; If you have some (actually, a lot of) spare time you can watch my class from TRC2021 where I cover a lot about symbols/sigils/object interaction in Raku: https://conf.ra

Re: pairs of separators from a string

2021-08-22 Thread William Michels via perl6-users
Hi Marc! Is it just even/odd elements that you want to separate out? If so, maybe .grep() is your friend here: > my $string0 = q!""''(){}[]! ""''(){}[] > $string0.comb[(0..*-1).grep(* %% 2)].say; (" ' ( { [) > $string0.comb[(0..*-1).grep(* % 2)].say; (" ' ) } ]) It sounds like you have some inte

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

2021-08-22 Thread Brian Duggan
On Sunday, August 22, Marc Chantreux wrote: > 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 think it's possible to avoid the expl

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

2021-08-22 Thread Fernando Santagata
On Sun, Aug 22, 2021 at 2:58 PM Marc Chantreux wrote: > so of course i tried > > my (@a, @b) = { .[0,2…∞], .[1,3…∞] }.(q.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 fo

Re: pairs of separators from a string

2021-08-22 Thread Marc Chantreux
hello William, > your string, or whether-or-not some might be nested within each other. You > show a lone ampersand ("&") at the beginning of your example, but other > strings may not be so simple. really sorry about this artefact from previous attempts :( > > $string.comb(/ ( <:Ps> ~ <:Pe> .?)

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

2021-08-22 Thread Marc Chantreux
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,

Re: pairs of separators from a string

2021-08-22 Thread William Michels via perl6-users
Hi Marc (and yary)! I'll give this a shot, focusing on bracket pairs. It's not clear from your question whether there's any inherent order to the bracket characters in your string, or whether-or-not some might be nested within each other. You show a lone ampersand ("&") at the beginning of your ex

Re: pairs of separators from a string

2021-08-21 Thread Vadim Belman
I guess you need something like this: my ($a, $b) = { @^a[0,2...Inf], @a[1,3...Inf] }.(q<(){}[]>.comb); say $a; say $b Best regards, Vadim Belman > On Aug 21, 2021, at 3:04 AM, Marc Chantreux wrote: > > hello, > > i would like to get the list of opening (α) and closing > (ω) separators from

Re: pairs of separators from a string

2021-08-21 Thread yary
This reminds me of "the comma rule" which I haven't quite internalized yet. This gets a little closer map { .[0,2…∞], .[1,3…∞] }, ("012345".comb,) (((0 2 4) (1 3 5))) 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