| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Venus::Role::Mappable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
412
|
use 5.018; |
|
|
21
|
|
|
|
|
84
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
21
|
|
|
21
|
|
142
|
use strict; |
|
|
21
|
|
|
|
|
48
|
|
|
|
21
|
|
|
|
|
481
|
|
|
6
|
21
|
|
|
21
|
|
299
|
use warnings; |
|
|
21
|
|
|
|
|
200
|
|
|
|
21
|
|
|
|
|
653
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
21
|
|
|
21
|
|
122
|
use Venus::Role 'fault'; |
|
|
21
|
|
|
|
|
43
|
|
|
|
21
|
|
|
|
|
146
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# AUDIT |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub AUDIT { |
|
13
|
35
|
|
|
35
|
0
|
103
|
my ($self, $from) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
35
|
|
33
|
|
|
209
|
my $name = ref $self || $self; |
|
16
|
|
|
|
|
|
|
|
|
17
|
35
|
50
|
|
|
|
372
|
if (!$from->can('all')) { |
|
18
|
0
|
|
|
|
|
0
|
fault "${from} requires 'all' to consume ${name}"; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
35
|
50
|
|
|
|
167
|
if (!$from->can('any')) { |
|
22
|
0
|
|
|
|
|
0
|
fault "${from} requires 'any' to consume ${name}"; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
35
|
50
|
|
|
|
228
|
if (!$from->can('call')) { |
|
26
|
0
|
|
|
|
|
0
|
fault "${from} requires 'call' to consume ${name}"; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
35
|
50
|
|
|
|
166
|
if (!$from->can('count')) { |
|
30
|
0
|
|
|
|
|
0
|
fault "${from} requires 'count' to consume ${name}"; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
35
|
50
|
|
|
|
163
|
if (!$from->can('delete')) { |
|
34
|
0
|
|
|
|
|
0
|
fault "${from} requires 'delete' to consume ${name}"; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
35
|
50
|
|
|
|
151
|
if (!$from->can('each')) { |
|
38
|
0
|
|
|
|
|
0
|
fault "${from} requires 'each' to consume ${name}"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
35
|
50
|
|
|
|
148
|
if (!$from->can('empty')) { |
|
42
|
0
|
|
|
|
|
0
|
fault "${from} requires 'empty' to consume ${name}"; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
35
|
50
|
|
|
|
178
|
if (!$from->can('exists')) { |
|
46
|
0
|
|
|
|
|
0
|
fault "${from} requires 'exists' to consume ${name}"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
35
|
50
|
|
|
|
207
|
if (!$from->can('grep')) { |
|
50
|
0
|
|
|
|
|
0
|
fault "${from} requires 'grep' to consume ${name}"; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
35
|
50
|
|
|
|
156
|
if (!$from->can('iterator')) { |
|
54
|
0
|
|
|
|
|
0
|
fault "${from} requires 'iterator' to consume ${name}"; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
35
|
50
|
|
|
|
190
|
if (!$from->can('keys')) { |
|
58
|
0
|
|
|
|
|
0
|
fault "${from} requires 'keys' to consume ${name}"; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
35
|
50
|
|
|
|
156
|
if (!$from->can('map')) { |
|
62
|
0
|
|
|
|
|
0
|
fault "${from} requires 'map' to consume ${name}"; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
35
|
50
|
|
|
|
185
|
if (!$from->can('none')) { |
|
66
|
0
|
|
|
|
|
0
|
fault "${from} requires 'none' to consume ${name}"; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
35
|
50
|
|
|
|
181
|
if (!$from->can('one')) { |
|
70
|
0
|
|
|
|
|
0
|
fault "${from} requires 'one' to consume ${name}"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
35
|
50
|
|
|
|
163
|
if (!$from->can('pairs')) { |
|
74
|
0
|
|
|
|
|
0
|
fault "${from} requires 'pairs' to consume ${name}"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
35
|
50
|
|
|
|
158
|
if (!$from->can('random')) { |
|
78
|
0
|
|
|
|
|
0
|
fault "${from} requires 'random' to consume ${name}"; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
35
|
50
|
|
|
|
155
|
if (!$from->can('reverse')) { |
|
82
|
0
|
|
|
|
|
0
|
fault "${from} requires 'reverse' to consume ${name}"; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
35
|
50
|
|
|
|
155
|
if (!$from->can('slice')) { |
|
86
|
0
|
|
|
|
|
0
|
fault "${from} requires 'slice' to consume ${name}"; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
35
|
|
|
|
|
95
|
return $self; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Venus::Role::Mappable - Mappable Role |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Mappable Role for Perl 5 |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
package Example; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
use Venus::Class; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
with 'Venus::Role::Mappable'; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub all; |
|
117
|
|
|
|
|
|
|
sub any; |
|
118
|
|
|
|
|
|
|
sub call; |
|
119
|
|
|
|
|
|
|
sub count; |
|
120
|
|
|
|
|
|
|
sub delete; |
|
121
|
|
|
|
|
|
|
sub each; |
|
122
|
|
|
|
|
|
|
sub empty; |
|
123
|
|
|
|
|
|
|
sub exists; |
|
124
|
|
|
|
|
|
|
sub grep; |
|
125
|
|
|
|
|
|
|
sub iterator; |
|
126
|
|
|
|
|
|
|
sub keys; |
|
127
|
|
|
|
|
|
|
sub map; |
|
128
|
|
|
|
|
|
|
sub none; |
|
129
|
|
|
|
|
|
|
sub one; |
|
130
|
|
|
|
|
|
|
sub pairs; |
|
131
|
|
|
|
|
|
|
sub random; |
|
132
|
|
|
|
|
|
|
sub reverse; |
|
133
|
|
|
|
|
|
|
sub slice; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
package main; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $example = Example->new; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# $example->random; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This package provides a specification for the consuming package to implement |
|
146
|
|
|
|
|
|
|
methods that makes the object mappable. See L and L |
|
147
|
|
|
|
|
|
|
as other examples of mappable classes. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 METHODS |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This package provides the following methods: |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 all |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
all(CodeRef $code) (Bool) |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The all method should return true if the callback returns true for all of the |
|
162
|
|
|
|
|
|
|
elements provided. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
I> |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over 4 |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item all example 1 |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# given: synopsis; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my $all = $example->all(sub { |
|
173
|
|
|
|
|
|
|
# ... |
|
174
|
|
|
|
|
|
|
}); |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=back |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 any |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
any(CodeRef $code) (Bool) |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
The any method should return true if the callback returns true for any of the |
|
185
|
|
|
|
|
|
|
elements provided. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
I> |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=over 4 |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item any example 1 |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# given: synopsis; |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
my $any = $example->any(sub { |
|
199
|
|
|
|
|
|
|
# ... |
|
200
|
|
|
|
|
|
|
}); |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=back |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 count |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
count() (Num) |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
The count method should return the number of top-level element in the data |
|
211
|
|
|
|
|
|
|
structure. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
I> |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=over 4 |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item count example 1 |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# given: synopsis; |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my $count = $example->count; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=back |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=cut |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head2 delete |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
delete(Str $key) (Any) |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
The delete method returns should remove the item in the data structure based on |
|
235
|
|
|
|
|
|
|
the key provided, returning the item. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
I> |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=over 4 |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item delete example 1 |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# given: synopsis; |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
my $delete = $example->delete(...); |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=back |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head2 each |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
each(CodeRef $code) (ArrayRef) |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
The each method should execute the callback for each item in the data structure |
|
259
|
|
|
|
|
|
|
passing the key and value as arguments. |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
I> |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=over 4 |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=item each example 1 |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
# given: synopsis; |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
my $results = $example->each(sub { |
|
273
|
|
|
|
|
|
|
# ... |
|
274
|
|
|
|
|
|
|
}); |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=back |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=cut |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head2 empty |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
empty() (Value) |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
The empty method should drop all items from the data structure. |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
I> |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=over 4 |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=item empty example 1 |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# given: synopsis; |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
my $empty = $example->empty; |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=back |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=cut |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head2 exists |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
exists(Str $key) (Bool) |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
The exists method should return true if the item at the key specified exists, |
|
308
|
|
|
|
|
|
|
otherwise it returns false. |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
I> |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=over 4 |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=item exists example 1 |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
# given: synopsis; |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
my $exists = $example->exists(...); |
|
322
|
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=back |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=cut |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=head2 grep |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
grep(CodeRef $code) (ArrayRef) |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
The grep method should execute a callback for each item in the array, passing |
|
332
|
|
|
|
|
|
|
the value as an argument, returning a value containing the items for which the |
|
333
|
|
|
|
|
|
|
returned true. |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
I> |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=over 4 |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=item grep example 1 |
|
343
|
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
# given: synopsis; |
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
my $results = $example->grep(sub { |
|
347
|
|
|
|
|
|
|
# ... |
|
348
|
|
|
|
|
|
|
}); |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=back |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=cut |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=head2 iterator |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
iterator() (CodeRef) |
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
The iterator method should return a code reference which can be used to iterate |
|
359
|
|
|
|
|
|
|
over the data structure. Each time the iterator is executed it will return the |
|
360
|
|
|
|
|
|
|
next item in the data structure until all items have been seen, at which point |
|
361
|
|
|
|
|
|
|
the iterator will return an undefined value. |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
I> |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=over 4 |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
=item iterator example 1 |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
# given: synopsis; |
|
373
|
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
my $iterator = $example->iterator; |
|
375
|
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=back |
|
377
|
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=cut |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
=head2 keys |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
keys() (ArrayRef) |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
The keys method should return an array reference consisting of the keys of the |
|
385
|
|
|
|
|
|
|
data structure. |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
I> |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=over 4 |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=item keys example 1 |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
# given: synopsis; |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
my $keys = $example->keys; |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=back |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=cut |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=head2 map |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
map(CodeRef $code) (ArrayRef) |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
The map method should iterate over each item in the data structure, executing |
|
409
|
|
|
|
|
|
|
the code reference supplied in the argument, passing the routine the value at |
|
410
|
|
|
|
|
|
|
the current position in the loop and returning an array reference containing |
|
411
|
|
|
|
|
|
|
the items for which the argument returns a value or non-empty list. |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
I> |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=over 4 |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=item map example 1 |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
# given: synopsis; |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
my $results = $example->map(sub { |
|
425
|
|
|
|
|
|
|
# ... |
|
426
|
|
|
|
|
|
|
}); |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=back |
|
429
|
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=cut |
|
431
|
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=head2 none |
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
none(CodeRef $code) (Bool) |
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
The none method should return true if none of the items in the data structure |
|
437
|
|
|
|
|
|
|
meet the criteria set by the operand and rvalue. |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
I> |
|
443
|
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=over 4 |
|
445
|
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=item none example 1 |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
# given: synopsis; |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
my $none = $example->none(sub { |
|
451
|
|
|
|
|
|
|
# ... |
|
452
|
|
|
|
|
|
|
}); |
|
453
|
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
=back |
|
455
|
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
=cut |
|
457
|
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=head2 one |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
one(CodeRef $code) (Bool) |
|
461
|
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
The one method should return true if only one of the items in the data |
|
463
|
|
|
|
|
|
|
structure meet the criteria set by the operand and rvalue. |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
I> |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
=over 4 |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
=item one example 1 |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
# given: synopsis; |
|
475
|
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
my $one = $example->one(sub { |
|
477
|
|
|
|
|
|
|
# ... |
|
478
|
|
|
|
|
|
|
}); |
|
479
|
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
=back |
|
481
|
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=cut |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
=head2 pairs |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
pairs(CodeRef $code) (Tuple[ArrayRef, ArrayRef]) |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
The pairs method should return an array reference of tuples where each tuple is |
|
489
|
|
|
|
|
|
|
an array reference having two items corresponding to the key and value for each |
|
490
|
|
|
|
|
|
|
item in the data structure. |
|
491
|
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
I> |
|
496
|
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=over 4 |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=item pairs example 1 |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
# given: synopsis; |
|
502
|
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
my $pairs = $example->pairs(sub { |
|
504
|
|
|
|
|
|
|
# ... |
|
505
|
|
|
|
|
|
|
}); |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=back |
|
508
|
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
=cut |
|
510
|
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=head2 random |
|
512
|
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
random() (Any) |
|
514
|
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
The random method should return a random item from the data structure. |
|
516
|
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
I> |
|
521
|
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
=over 4 |
|
523
|
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=item random example 1 |
|
525
|
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
# given: synopsis; |
|
527
|
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
my $random = $example->random; |
|
529
|
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
=back |
|
531
|
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=cut |
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
=head2 reverse |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
reverse() (ArrayRef) |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
The reverse method should returns an array reference containing the items in |
|
539
|
|
|
|
|
|
|
the data structure in reverse order if the items in the data structure are |
|
540
|
|
|
|
|
|
|
ordered. |
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
I> |
|
546
|
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=over 4 |
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=item reverse example 1 |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
# given: synopsis; |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
my $reverse = $example->reverse; |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=back |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=cut |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
=head2 slice |
|
560
|
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
slice(Str @keys) (ArrayRef) |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
The slice method should return a new data structure containing the elements in |
|
564
|
|
|
|
|
|
|
the invocant at the key(s) specified in the arguments. |
|
565
|
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
I> |
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
=over 4 |
|
572
|
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=item slice example 1 |
|
574
|
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
# given: synopsis; |
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
my $slice = $example->slice(...); |
|
578
|
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=back |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=cut |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=head1 AUTHORS |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
Awncorp, C |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=cut |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=head1 LICENSE |
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
|
592
|
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
|
594
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
|
595
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
=cut |