I tried combining Larry's code and Yary's code, variously using "state" or "INIT" or "BEGIN". This is what I saw:
~$ raku -e 'for <AA NN> -> $alpha { for (1..14) { print (state $ = $alpha)++ ~ " " } }' AA AB AC AD AE AF AG AH AI AJ AK AL AM AN NN NO NP NQ NR NS NT NU NV NW NX NY NZ OA ~$ raku -e 'for <AA NN> -> $alpha { for (1..14) { print (INIT $ = $alpha)++ ~ " " } }' 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ~$ raku -e 'for <AA NN> -> $alpha { for (1..14) { print (BEGIN $ = $alpha)++ ~ " " } }' 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Expected? --Bill. On Tue, Sep 1, 2020 at 11:44 AM yary <not....@gmail.com> wrote: > > > Thanks, that's cool, and shows me something I was wondering about > > On Tue, Sep 1, 2020 at 11:36 AM Larry Wall <la...@wall.org> wrote: >> >> If you want to re-initialize a state variable, it's probably better to make >> it explicit with the state declarator: >> >> $ raku -e "for <a b> { for (1..2) { say (state $ = 'AAA')++ } }" >> AAA >> AAB >> AAA >> AAB > > > $ raku -e 'for <AA OO> -> $alpha { for (1..3) { say (state $ = $alpha)++ } }' > AA > AB > AC > OO > OP > OQ >