This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
rcmlz done 10:14
mcmillhj What is the best way to map over two elements of an array at the same time (with overlaps)? For example given `[1, 2, 3, 4, 5]` you would produce `(1 2) (2 3) (3 4) (4 5)`. I had been using `@a Z a.tail(* - 1)` but wasn't sure if there a simpler / more concise way to do this? 21:00
mcmillhj Maybe something with rotor? 21:02
nemokosch yep 21:02
first off, @a Z @a.skip is a direct improvement
but the OG version would be @a.rotor(2 => -1)
mcmillhj shoot, I missed that in the docs. `@a.rotor(2 => -1)` is what I was looking for. 21:03
nemokosch there is a good video about tricks like this, one sec
www.youtube.com/watch?v=LvFTyvYM-ds
mcmillhj oooh, thank you !
mcmillhj Sorry, another question. Is there a way to apply the reduction meta operator from the right? So if I have an array [1,2,3] I would get 2-3=1, 1-1=0 23:03
oops, 2-3=-1, 1-1 = 2 23:05
oops, 2-3=-1, 1- -1 = 2
nemokosch the associativity of the operator decides 23:12