Slip Reference
A kind of List that automatically flattens into an outer container
What it is #
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method List #
multi method List(Slip:D: --> List:D)
Returns List:D.
Turns it into a list.
sub slip #
multi slip(--> Empty)
multi slip(@args --> Slip:D)
multi slip(+args --> Slip:D)
Returns Empty or Slip:D.
Creates a Slip from its arguments by calling .Slip on the object formed by them. Returns Empty if called with void arguments.
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
4 no-output · 4 ok
class Slip is List {}Not executed: the documentation states no expected output for this example.
say <a b c>.map({ ($_, $_.uc).Slip }).join('|'); # OUTPUT: «a|A|b|B|c|C»a|A|b|B|c|C
Documentation, Rakudo and Raku++ all agree.
say <a b c>.map({ $_, $_.uc }).join('|'); # OUTPUT: «a A|b B|c C»a A|b B|c C
Documentation, Rakudo and Raku++ all agree.
# This says "1" and then says "2", rather than saying "(1 2)"
.say for gather {
take slip(1, 2);
}Not executed: the documentation states no expected output for this example.
my $l = (1, 2, 3); say (1, slip 2, 3).raku; # says (1, 2, 3) , slips 2, 3 into (1, …) say (0, slip $l, 4).raku; # says (0, $(1, 2, 3), 4) , $l does not break apart say (0, slip $l).raku; # says (0, 1, 2, 3) , slips from $l into (0, …) say (0, $l.Slip).raku; # says (0, 1, 2, 3) , slips from $l into (0, …) say (0, $l.Slip, 4).raku; # says (0, 1, 2, 3, 4) , slips from $l into (0, …, 4) say (|$l).raku; # says slip(1, 2, 3) , breaks apart $l say (0, (|$l, 4), 5); # says (0 (1 2 3 4) 5) , slips from $l into (…, 4) say (0, ($l.Slip, 4), 5); # says (0 (1 2 3 4) 5) , slips from $l into (…, 4) say (0, (slip $l, 4), 5); # says (0 (1 2 3) 4 5) , slips ($l, 4) into (0, …, 5) say (0, ($l, 4).Slip, 5); # says (0 (1 2 3) 4 5) , slips ($l, 4) into (0, …, 5)
Not executed: the documentation states no expected output for this example.
my \l = gather for 1..10 -> $a, $b { take |($a, $b) }; say l.raku;
# OUTPUT: «((1, 2), (3, 4), (5, 6), (7, 8), (9, 10)).Seq»
my \m= gather for 1..10 -> $a, $b { take ($a, $b).Slip }; say m.raku;
# OUTPUT: «(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Seq»((1, 2), (3, 4), (5, 6), (7, 8), (9, 10)).Seq
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Seq
Documentation, Rakudo and Raku++ all agree.
say "".comb ~~ Empty; # OUTPUT: «True»
True
Documentation, Rakudo and Raku++ all agree.
do if 0 {};
(42 if 0);
do with Any {};
(42 with Any);Not executed: the documentation states no expected output for this example.