Combined from primary sources listed below.
See primary docmentation in context for routine skip.
multi method skip()
multi method skip(Whatever)
multi method skip(Callable:D $w)
multi method skip(Int() $n)
multi method skip($skip, $produce)
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.
See primary docmentation in context for method skip.
method skip-one(Iterator:D: $target --> Mu)
Should skip producing one value. The return value should be truthy if the skip was successful and falsy if there were no values to be skipped:
my $i = <a b>.iterator;
say $i.skip-one; say $i.pull-one; say $i.skip-one
# OUTPUT: «1b0»
The Iterator role implements this method as a call pull-one and returning whether the value obtained was not IterationEnd.
See primary docmentation in context for method skip.
method skip-at-least(Iterator:D: $target, int $to-skip --> Mu)
Should skip producing $to-skip values. The return value should be truthy if the skip was successful and falsy if there were not enough values to be skipped:
my $i = <a b c>.iterator;
say $i.skip-at-least(2); say $i.pull-one; say $i.skip-at-least(20);
# OUTPUT: «1c0»
The Iterator role implements this method as a loop calling skip-one and returning whether it returned a truthy value sufficient number of times.
See primary docmentation in context for method skip.
method skip-at-least-pull-one(Iterator:D: $target, int $to-skip --> Mu)
Should skip producing $to-skip values and if the iterator is still not exhausted, produce and return the next value. Should return IterationEnd if the iterator got exhausted at any point:
my $i = <a b c>.iterator;
say $i.skip-at-least-pull-one(2);
say $i.skip-at-least-pull-one(20) =:= IterationEnd;
# OUTPUT: «cTrue»
The Iterator role implements this method as calling skip-at-least and then calling pull-one if it was not exhausted yet.
See primary docmentation in context for method skip.
method skip(Supply:D: Int(Cool) $number = 1 --> Supply:D)
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 = Supplier.new;
my $supply = $supplier.Supply;
$supply = $supply.skip(3);
$supply.tap({ say $_ });
$supplier.emit($_) for 1..10; # OUTPUT: «45678910»
See primary docmentation in context for method skip.
multi method skip(Seq:D:)
multi method skip(Seq:D: Whatever)
multi method skip(Seq:D: Callable:D $w)
multi method skip(Seq:D: Int() $n)
multi method skip(Seq:D: $skip, $produce)
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)»
See primary docmentation in context for sub skip.
sub skip-rest($reason = '<unknown>')
Skip the remaining tests. If the remainder of the tests in the test file would all fail due to some condition, use this function to skip them, providing an optional $reason as to why.
my $location; sub womble { ... }; ...;
unless $location ~~ "Wimbledon Common" {
skip-rest "We can't womble, the remaining tests will fail";
exit;
}
# tests requiring functional wombling
ok womble();
# ...
Note that skip-rest requires a plan to be set, otherwise the skip-rest call will throw an error. Note that skip-rest does not exit the test run. Do it manually, or use conditionals to avoid running any further tests.
See also plan :skip-all('...') to avoid running any tests at all and bail-out to abort the test run and mark it as failed.
See primary docmentation in context for sub skip.
multi skip()
multi skip($reason, $count = 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($arg) { ... } ;
if $*KERNEL ~~ 'linux' {
is num-forward-slashes("/a/b"), 2;
is num-forward-slashes("/a//b".IO.cleanup), 2;
}
else {
skip "Can't use forward slashes on Windows", 2;
}
Note that if you mark a test as skipped, you must also prevent that test from running.