@@ -41,8 +41,8 @@ Defined as:
41
41
Interprets the invocant as a list and creates an
42
42
C < any > -L < Junction|/type/Junction > from it.
43
43
44
- say so 2 == <1 2 3>.any; # True
45
- say so 5 == <1 2 3>.any; # False
44
+ say so 2 == <1 2 3>.any; # OUTPUT: « True»
45
+ say so 5 == <1 2 3>.any; # OUTPUT: « False»
46
46
47
47
= head2 method all
48
48
@@ -53,8 +53,8 @@ Defined as:
53
53
Interprets the invocant as a list and creates an
54
54
C < all > -L < Junction|/type/Junction > from it.
55
55
56
- say so 1 < <2 3 4>.all; # True
57
- say so 3 < <2 3 4>.all; # False
56
+ say so 1 < <2 3 4>.all; # OUTPUT: « True»
57
+ say so 3 < <2 3 4>.all; # OUTPUT: « False»
58
58
59
59
= head2 method one
60
60
@@ -65,8 +65,8 @@ Defined as:
65
65
Interprets the invocant as a list and creates a
66
66
C < one > -L < Junction|/type/Junction > from it.
67
67
68
- say so 1 == (1, 2, 3).one; # True
69
- say so 1 == (1, 2, 1).one; # False
68
+ say so 1 == (1, 2, 3).one; # OUTPUT: « True»
69
+ say so 1 == (1, 2, 1).one; # OUTPUT: « False»
70
70
71
71
= head2 method none
72
72
@@ -77,15 +77,15 @@ Defined as:
77
77
Interprets the invocant as a list and creates a
78
78
C < none > -L < Junction|/type/Junction > from it.
79
79
80
- say so 1 == (1, 2, 3).none; # False
81
- say so 4 == (1, 2, 3).none; # True
80
+ say so 1 == (1, 2, 3).none; # OUTPUT: « False»
81
+ say so 4 == (1, 2, 3).none; # OUTPUT: « True»
82
82
83
83
= head2 method list
84
84
85
85
Interprets the invocant as a list, and returns that L < List|/type/List > .
86
86
87
- say 42.list.^name; # List
88
- say 42.list.elems; # 1
87
+ say 42.list.^name; # OUTPUT: « List»
88
+ say 42.list.elems; # OUTPUT: «1»
89
89
90
90
= head2 method push
91
91
@@ -95,9 +95,9 @@ implements C<Positional> already. The argument provided will then be pushed
95
95
into the newly created Array.
96
96
97
97
my %h;
98
- dd %h<a>; # Any (and therefor undefined)
98
+ dd %h<a>; # Any (and therefore undefined)
99
99
%h<a>.push(1); # .push on Any
100
- dd %h; # «Hash %h = {:a($[1])}» # please note the Array
100
+ dd %h; # «Hash %h = {:a($[1])}» # please note the Array
101
101
102
102
= head2 routine reverse
103
103
@@ -113,19 +113,19 @@ to reverse the characters in a string, use L<flip>.
113
113
114
114
Examples:
115
115
116
- say <hello world!>.reverse; # (world! hello)
117
- say reverse ^10; # (9 8 7 6 5 4 3 2 1 0)
116
+ say <hello world!>.reverse; # OUTPUT: « (world! hello)»
117
+ say reverse ^10; # OUTPUT: « (9 8 7 6 5 4 3 2 1 0)»
118
118
119
119
= head2 method sort
120
120
121
121
Sorts iterables with C < infix:<cmp> > or given code object and returns a new C < List > .
122
122
123
123
Examples:
124
124
125
- say <b c a>.sort; # (a b c)
126
- say 'bca'.comb.sort.join; # abc
127
- say 'bca'.comb.sort({$^b cmp $^a}).join; # cba
128
- say '231'.comb.sort(&infix:«<=>»).join; # 123
125
+ say <b c a>.sort; # OUTPUT: « (a b c)»
126
+ say 'bca'.comb.sort.join; # OUTPUT: « abc»
127
+ say 'bca'.comb.sort({$^b cmp $^a}).join; # OUTPUT: « cba»
128
+ say '231'.comb.sort(&infix:«<=>»).join; # OUTPUT: « 123»
129
129
130
130
= head2 method map
131
131
@@ -178,8 +178,8 @@ L<halting problem|https://en.wikipedia.org/wiki/Halting_problem> for you.
178
178
If you flat an infinite list C < .flat > may return that infinite list, eating
179
179
all your RAM in the process.
180
180
181
- say ((1, 2), (3)).elems; # 2
182
- say ((1, 2), (3)).flat.elems; # 3
181
+ say ((1, 2), (3)).elems; # OUTPUT: «2»
182
+ say ((1, 2), (3)).flat.elems; # OUTPUT: «3»
183
183
184
184
Please not that C < flat > does not recurse into sub lists. You have to recurse by
185
185
hand or reconsider your data structures. A single level of nesting can often be
@@ -188,30 +188,29 @@ signatures. For deeper structures you may consider
188
188
L < gather/take|/syntax/gather take > to create a lazy list.
189
189
190
190
my @a = [[1,2,3],[[4,5],6,7]];
191
- say gather deepmap *.take, @a;
192
- # (1 2 3 4 5 6 7)
191
+ say gather deepmap *.take, @a; # OUTPUT: «(1 2 3 4 5 6 7)»
193
192
194
193
= head2 method eager
195
194
196
195
Interprets the invocant as a list, evaluates it eagerly, and returns that
197
196
list.
198
197
199
- say (1..10).eager; # (1 2 3 4 5 6 7 8 9 10)
198
+ say (1..10).eager; # OUTPUT: « (1 2 3 4 5 6 7 8 9 10)»
200
199
201
200
= head2 method elems
202
201
203
202
Interprets the invocant as a list, and returns the number of elements in the
204
203
list.
205
204
206
- say 42.elems; # 1
207
- say <a b c>.elems; # 3
205
+ say 42.elems; # OUTPUT: «1»
206
+ say <a b c>.elems; # OUTPUT: «3»
208
207
209
208
= head2 method end
210
209
211
210
Interprets the invocant as a list, and returns the last index of that list.
212
211
213
- say 6.end; # 0
214
- say <a b c>.end; # 2
212
+ say 6.end; # OUTPUT: «0»
213
+ say <a b c>.end; # OUTPUT: «2»
215
214
216
215
= head2 method pairup
217
216
@@ -224,7 +223,7 @@ constructs a pair from them, unless the item in the key position already is a
224
223
pair (in which case the pair is passed is passed through, and the next
225
224
list item, if any, is considered to be a key again).
226
225
227
- say (a => 1, 'b', 'c').pairup.perl; # (:a(1), :b("c")).Seq
226
+ say (a => 1, 'b', 'c').pairup.perl; # OUTPUT: « (:a(1), :b("c")).Seq»
228
227
229
228
= head2 sub exit
230
229
@@ -247,14 +246,14 @@ Defined as:
247
246
248
247
Forces given object to be evaluated in item context and returns the value of it.
249
248
250
- say item([1,2,3]).perl; # $[1, 2, 3]
251
- say item({ apple => 10 }).perl; # ${:apple(10)}
252
- say item("abc").perl; # "abc"
249
+ say item([1,2,3]).perl; # OUTPUT: « $[1, 2, 3]»
250
+ say item({ apple => 10 }).perl; # OUTPUT: « ${:apple(10)}»
251
+ say item("abc").perl; # OUTPUT: « "abc"»
253
252
254
253
You can also use C < $ > as item contextualizer.
255
254
256
- say $[1,2,3].perl; # $[1, 2, 3]
257
- say $("abc").perl; # "abc"
255
+ say $[1,2,3].perl; # OUTPUT: « $[1, 2, 3]»
256
+ say $("abc").perl; # OUTPUT: « "abc"»
258
257
259
258
= end pod
260
259
0 commit comments