@@ -14,17 +14,37 @@ into the result without nesting:
14
14
15
15
say <a b c>.map({ ($_, $_.uc).Slip }).join('|'); # a|A|b|B|c|C
16
16
17
- In contrast, when returning an oridinar List, the resulting list is nested:
17
+ In contrast, when returning an ordinary List, the resulting list is nested:
18
18
19
19
say <a b c>.map({ $_, $_.uc }).join('|'); # a A|b B|c C
20
20
21
21
To create a C < Slip > , either coerce another list-like type to it by calling the
22
22
C < Slip > method, or use the C < slip > subroutine:
23
23
24
+ # This says "1" and then says "2", rather than saying "(1 2)"
24
25
.say for gather {
25
26
take slip(1, 2);
26
27
}
27
28
29
+ A C < Slip > may also be created by using the C < prefix:<|> > operator. This differs
30
+ from the C < slip > subroutine in both precedence and treatment of single arguments.
31
+ In fact, C < prefix:<|> > only takes a single argment, so it that way, it behaves
32
+ closer to the C < .Slip > method than the C < slip > subroutine.
33
+
34
+ my $l = (1,2,3);
35
+ say (1, slip 2,3).perl; # says (1,2,3) , slips 2,3 into (1, …)
36
+ say (0, slip $l).perl; # says (0,$(1,2,3)) , $l does not break apart
37
+ say (0, $l.Slip).perl; # says (0,1,2,3) , slips from $l into (0, …)
38
+ say (|$l).perl; # says slip(1,2,3) , breaks apart $l
39
+ say (0, (|$l, 4), 5); # says (0 (1 2 3 4) 5), slips from $l into (…, 4)
40
+ say (0, ($l.Slip, 4), 5); # says (0 (1 2 3 4) 5), slips from $l into (…, 4)
41
+ say (0, (slip $l, 4), 5); # says (0 (1 2 3) 4 5), slips ($l,4) into (0, …, 5)
42
+ say (0, ($l, 4).Slip, 5); # says (0 (1 2 3) 4 5), slips ($l,4) into (0, …, 5)
43
+
44
+ Loops that do not want to produce a value for an iteration use C < Slips > , rather
45
+ than empty C < List > s to do so, as do C < if > statements that do not run their
46
+ blocks.
47
+
28
48
= head1 Methods
29
49
30
50
= head2 sub slip
0 commit comments