[better solution] pairs of separators from a string

2021-08-24 Thread Marc Chantreux
hello everyone, I made a mistake while replying to all of us so anwsers never reached your boxes. I'll summerize in one answer: Bill: > Is it just even/odd elements that you want to separate out? If so, maybe > .grep() is your friend here I don't think it is: 0, 2 ... * seems to be * closer to

Re: [better solution] pairs of separators from a string

2021-08-24 Thread William Michels via perl6-users
Hi Marc, My understanding is that ranges are pretty cheap to construct, and in any case, the range @x[0..*-1] is just the index of all elements in @x. The .grep() approach may be most useful if you have a function (e.g. %, %%, and .is-prime shown below): > (0...9) (0 1 2 3 4 5 6 7 8 9) > (0...9)[

Re: [better solution] pairs of separators from a string

2021-08-24 Thread yary
Hi Bill, When building a range that's an arithmetic or geometric progression, the sequence operator is a little quicker to type. And thus also more likely to be understood more quickly too. > ('a' .. 'h')[(0..*-1).grep: * %% 2 ] (a c e g) > ('a' .. 'h')[ 0, 2 ... * ] (a c e g) > ('a' .. 'h')[(0.