It does not move elements around (assuming push/pop are doing the natural thing) and has only one temporary copy.@a = (1); for (1..10) { print "@a\n"; @na=(); for (@a) { $na[-1] == $_ ? $na[-2]++ : push @na, (1, $_) } @a=@na; }
In reply to RE: Generating a Pattern
by fundflow
in thread Generating a Pattern
by japhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |