In Seq§
See primary documentation in context for method skip
multi method skip(Seq:)multi method skip(Seq: Whatever)multi method skip(Seq: Callable )multi method skip(Seq: Int() )multi method skip(Seq: , )
Returns a Seq containing whatever is left of the invocant after throwing away $n
of the next available values. Negative values of $n
count as 0. Also can take a WhateverCode
to indicate how many values to skip from the end. Will block on lazy Seqs until the requested number of values have been discarded.
say (1..5).Seq.skip; # OUTPUT: «(2 3 4 5)»say (1..5).Seq.skip(3); # OUTPUT: «(4 5)»say (1..5).Seq.skip(5); # OUTPUT: «()»say (1..5).Seq.skip(-1); # OUTPUT: «(1 2 3 4 5)»
Calling it with Whatever
will return an empty Seq
:
say <1 2 3>.Seq.skip(*); # OUTPUT: «()»
The multi that uses a Callable is intended mainly to be used this way:
say (1..5).Seq.skip(*-3); # OUTPUT: «(3 4 5)»
Instead of throwing away the first $n
elements, it throws away everything but the elements indicated by the WhateverCode, in this case all but the last three elements.
As of language version 6.e
(early implementation exists in Rakudo compiler 2022.12+), it is also possible to specify multiple argument values. These are then interpreted as number of values to produce, then skip, then produce, etc.
say (1..12).Seq.skip(2,3,4); # OUTPUT: «(3 4 5 10 11 12)»
This first skipped 2 values, then produced 3 values (3, 4, 5), skipped 4 values and then produced the rest (10, 11, 12).
If the final value specified is in a "produce" position, then the rest of the Seq
will be skipped. If the final value is in a "skip" position, then the rest of the Seq
will be produced.
say (1..10).Seq.skip(2,3,1,2); # OUTPUT: «(3 4 5 7 8)»say (1..10).Seq.skip(2,3,1); # OUTPUT: «(3 4 5 7 8 9 10)»
If a Whatever
is specified in a "produce" position, it will cause the rest of the Seq
to be produced. Otherwise, it will cause the rest if the Seq
to be skipped.
say (1..10).Seq.skip(2,*); # OUTPUT: «(3 4 5 6 7 8 9 10)»say (1..10).Seq.skip(2,3,*); # OUTPUT: «(3 4 5)»
If you want to start with producing values instead of skipping, specify 0 as the first value.
say (1..10).Seq.skip(0,3,4); # OUTPUT: «(1 2 3 8 9 10)»
If you want an unending repeating pattern of skips and produces, you can specify the arguments as an unending Seq
themselves.
say (^20).Seq.skip(|(2,3) xx *); # OUTPUT: «(0 1 5 6 10 11 15 16)»
In Supply§
See primary documentation in context for method skip
method skip(Supply: Int(Cool) = 1 --> Supply)
Returns a new Supply
which will emit all values from the given Supply
except for the first $number
values, which will be thrown away.
my = Supplier.new;my = .Supply;= .skip(3);.tap();.emit() for 1..10; # OUTPUT: «45678910»
In module Test§
See primary documentation in context for sub skip
multi skip()multi skip(, = 1)
Skip $count
tests, giving a $reason
as to why. By default only one test will be skipped. Use such functionality when a test (or tests) would die if run.
sub num-forward-slashes() ;if ~~ 'linux'else
Note that if you mark a test as skipped, you must also prevent that test from running.
In Any§
See primary documentation in context for routine skip
multi method skip()multi method skip(Whatever)multi method skip(Callable )multi method skip(Int() )multi method skip(, )
Creates a Seq
from 1-item list's iterator and uses Seq.skip
on it, please check that document for real use cases; calling skip
without argument is equivalent to skip(1)
.
multi skip(\skipper, +values)
As of release 2022.07 of the Rakudo compiler, there is also a "sub" version of skip
. It must have the skip specifier as the first argument. The rest of the arguments are turned into a Seq
and then have the skip
method called on it.