Printing mathematical series concisely in Raku

This might be a bit more idiomatic:

my @seq = 0, *+1 ... *;
say @seq[^4], @seq[7..10]

You don't need to use a lexical variable within the sequence; either Whatever or placeholder variables can safely be used within sequences. Then you can simply select the elements of the sequence you want printed. Which returns «(0 1 2 3)(7 8 9 10)␤»


You can skip the first N values on any Iterable or Sequence with skip:

for (^5).skip(3) {
    .say
}
# 3
# 4

If you don't specify a number, it will skip only one element.

Tags:

Sequence

Raku