Venus/Array.pm

filter: Statementstmt 96.7% 211 / 218 Branchbran 72.8% 67 / 92 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 83.6% 41 / 49 Podpod 94.5% 35 / 37 totaltotal 89.4% 357 / 399 CC 48 SCAR 12.5
CC
48
Cov
90%
all
6.2
none
6.2
find
6.1
CRAP 3.5
« Venus/Box.pm ↑ Summary Venus/Process.pm »
1 package Venus::Array;
2  
3 15 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 ▶use Venus::Class 'base', 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 15 base 'Venus::Kind::Value';
11  
12 15 with 'Venus::Role::Mappable';
13  
14 # METHODS
15  
16 sub all {
17 2 ▶ my ($self, $code) = @_;
Subroutine all: called CC=6 SCAR=18.3
Pod documented
18  
19 2 my $data = $self->get;
20  
21 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
22  
23 2 my $failed = 0;
24  
25 2 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 18 2 20
26 18 my $index = $i;
27 18 my $value = $data->[$i];
28  
29 18 local $_ = $value;
30 18 ▶ $failed++ if !$code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
unless &$code($index, $value) 0 18 18
31  
32 18 ▶ CORE::last if $failed;
Branch: 1 branch
BranchTrueFalseTotal
if $failed 0 18 18
33 }
34  
35 2 ▶ return $failed ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$failed ? : 0 2 2
36 }
37  
38 sub any {
39 2 ▶ my ($self, $code) = @_;
Subroutine any: called CC=6 SCAR=18.1
Pod documented
40  
41 2 my $data = $self->get;
42  
43 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
44  
45 2 my $found = 0;
46  
47 2 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 10 0 10
48 10 my $index = $i;
49 10 my $value = $data->[$i];
50  
51 10 local $_ = $value;
52 10 ▶ $found++ if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 2 8 10
53  
54 10 ▶ CORE::last if $found;
Branch: 1 branch
BranchTrueFalseTotal
if $found 2 8 10
55 }
56  
57 2 ▶ return $found ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$found ? : 2 0 2
58 }
59  
60 sub count {
61 3 ▶ my ($self) = @_;
Subroutine count: called CC=1 SCAR=0.0
Pod documented
62  
63 3 my $data = $self->get;
64  
65 3 return scalar(@$data);
66 }
67  
68 sub default {
69 183 ▶ return [];
Subroutine default: called CC=1 SCAR=0.0
Pod documented
70 }
71  
72 sub delete {
73 1 ▶ my ($self, $index) = @_;
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
74  
75 1 my $data = $self->get;
76  
77 1 return CORE::delete($data->[$index]);
78 }
79  
80 sub each {
81 5 ▶ my ($self, $code) = @_;
Subroutine each: called CC=4 SCAR=13.9
Pod documented
82  
83 5 my $data = $self->get;
84  
85 5 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 5 5
86  
87 5 my $result = [];
88  
89 5 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 27 5 32
90 27 my $index = $i;
91 27 my $value = $data->[$i];
92  
93 27 local $_ = $value;
94 27 CORE::push(@$result, $code->($index, $value));
95 }
96  
97 5 ▶ return wantarray ? (@$result) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 2 5
98 }
99  
100 sub empty {
101 1 ▶ my ($self) = @_;
Subroutine empty: called CC=1 SCAR=0.0
Pod documented
102  
103 1 my $data = $self->get;
104  
105 1 $#$data = -1;
106  
107 1 return $self;
108 }
109  
110 sub exists {
111 1 ▶ my ($self, $index) = @_;
Subroutine exists: called CC=2 SCAR=7.0
Pod documented
112  
113 1 my $data = $self->get;
114  
115 1 ▶ return $index <= $#{$data} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$index <= $#{$data;} ? : 1 0 1
116 }
117  
118 sub find {
119 7 ▶ my ($self, @args) = @_;
Subroutine find: called CC=6 SCAR=18.1
Pod documented
120  
121 7 my $seen = 0;
122 7 my $item = my $data = $self->get;
123  
124 7 ▶ for (my $i = 0; $i < @args; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @args) 16 7 23
125 16 ▶ if (ref($item) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $item eq 'ARRAY') { } 9 7 16
elsif (ref $item eq 'HASH') { } 6 1 7
126 9 ▶ if ($args[$i] !~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args[$i] =~ /^\d+$/u) 0 9 9
127 0 $item = undef;
128 0 $seen = 0;
129 0 CORE::last;
130 }
131 9 $seen = $args[$i] <= $#{$item};
132 9 $item = $item->[$args[$i]];
133 }
134 elsif (ref($item) eq 'HASH') {
135 6 $seen = exists $item->{$args[$i]};
136 6 $item = $item->{$args[$i]};
137 }
138 else {
139 1 $item = undef;
140 1 $seen = 0;
141 }
142 }
143  
144 7 ▶ return wantarray ? ($item, int(!!$seen)) : $item;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 6 7
145 }
146  
147 sub first {
148 1 ▶ my ($self) = @_;
Subroutine first: called CC=1 SCAR=0.0
Pod documented
149  
150 1 return $self->get->[0];
151 }
152  
153 sub get {
154 145 ▶ my ($self, @args) = @_;
Subroutine get: called CC=2 SCAR=6.9
Pod undocumented
155  
156 145 ▶ return $self->value if !int@args;
Branch: 1 branch
BranchTrueFalseTotal
unless int @args 141 4 145
157  
158 4 my ($index) = @args;
159  
160 4 return $self->value->[$index];
161 }
162  
163 sub grep {
164 2 ▶ my ($self, $code) = @_;
Subroutine grep: called CC=5 SCAR=16.2
Pod documented
165  
166 2 my $data = $self->get;
167  
168 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
169  
170 2 my $result = [];
171  
172 2 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 18 2 20
173 18 my $index = $i;
174 18 my $value = $data->[$i];
175  
176 18 local $_ = $value;
177 18 ▶ CORE::push(@$result, $value) if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 12 6 18
178 }
179  
180 2 ▶ return wantarray ? (@$result) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
181 }
182  
183 sub iterator {
184 2 ▶ my ($self) = @_;
Subroutine iterator: called CC=1 SCAR=0.0
Pod documented
185  
186 2 my $data = $self->get;
187  
188 2 my $i = 0;
189 2 my $j = 0;
190  
191 return sub {
192 20 ▶ return undef if $i > $#{$data};
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
if $i > $#{$data;} 2 18 20
193 18 ▶ return wantarray ? ($j++, $data->[$i++]) : $data->[$i++];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 9 9 18
194 }
195 2 }
196  
197 sub join {
198 3 ▶ my ($self, $delimiter) = @_;
Subroutine join: called CC=2 SCAR=6.9
Pod documented
199  
200 3 my $data = $self->get;
201  
202 3 ▶ return CORE::join($delimiter // '', @$data);
Condition100%2/2
$delimiter // ""
l!l
21
MC/DC100%1/1
$delimiter // ""
$delimiter
Truth table100%2/2
A
A= $delimiter
Aresult
11
00
203 }
204  
205 sub keyed {
206 1 ▶ my ($self, @keys) = @_;
Subroutine keyed: called CC=1 SCAR=0.0
Pod documented
207  
208 1 my $data = $self->get;
209  
210 1 my $i = 0;
211 1 return {map { $_ => $data->[$i++] } @keys};
212 }
213  
214 sub keys {
215 1 ▶ my ($self) = @_;
Subroutine keys: called CC=1 SCAR=0.0
Pod documented
216  
217 1 my $data = $self->get;
218  
219 1 return [0..$#{$data}];
220 }
221  
222 sub last {
223 1 ▶ my ($self) = @_;
Subroutine last: called CC=1 SCAR=0.0
Pod documented
224  
225 1 return $self->value->[-1];
226 }
227  
228 sub length {
229 1 ▶ my ($self) = @_;
Subroutine length: called CC=1 SCAR=0.0
Pod documented
230  
231 1 return $self->count;
232 }
233  
234 sub list {
235 2 ▶ my ($self) = @_;
Subroutine list: called CC=2 SCAR=6.9
Pod documented
236  
237 2 ▶ return wantarray ? (@{$self->value}) : scalar(@{$self->value});
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
238 }
239  
240 sub map {
241 2 ▶ my ($self, $code) = @_;
Subroutine map: called CC=4 SCAR=13.9
Pod documented
242  
243 2 my $data = $self->get;
244  
245 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
246  
247 2 my $result = [];
248  
249 2 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 18 2 20
250 18 my $index = $i;
251 18 my $value = $data->[$i];
252  
253 18 local $_ = $value;
254 18 CORE::push(@$result, $code->($index, $value));
255 }
256  
257 2 ▶ return wantarray ? (@$result) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
258 }
259  
260 sub none {
261 2 ▶ my ($self, $code) = @_;
Subroutine none: called CC=6 SCAR=18.3
Pod documented
262  
263 2 my $data = $self->get;
264  
265 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
266  
267 2 my $found = 0;
268  
269 2 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 18 2 20
270 18 my $index = $i;
271 18 my $value = $data->[$i];
272  
273 18 local $_ = $value;
274 18 ▶ $found++ if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 0 18 18
275  
276 18 ▶ CORE::last if $found;
Branch: 1 branch
BranchTrueFalseTotal
if $found 0 18 18
277 }
278  
279 2 ▶ return $found ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$found ? : 0 2 2
280 }
281  
282 sub one {
283 2 ▶ my ($self, $code) = @_;
Subroutine one: called CC=6 SCAR=18.1
Pod documented
284  
285 2 my $data = $self->get;
286  
287 2 ▶ $code = sub{} if !$code;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 2 2
288  
289 2 my $found = 0;
290  
291 2 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 18 2 20
292 18 my $index = $i;
293 18 my $value = $data->[$i];
294  
295 18 local $_ = $value;
296 18 ▶ $found++ if $code->($index, $value);
Branch: 1 branch
BranchTrueFalseTotal
if &$code($index, $value) 2 16 18
297  
298 18 ▶ CORE::last if $found > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $found > 1 0 18 18
299 }
300  
301 2 ▶ return $found == 1 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$found == 1 ? : 2 0 2
302 }
303  
304 sub pairs {
305 1 ▶ my ($self) = @_;
Subroutine pairs: called CC=2 SCAR=7.0
Pod documented
306  
307 1 my $data = $self->get;
308  
309 1 my $i = 0;
310 1 my $result = [map +[$i++, $_], @$data];
311  
312 1 ▶ return wantarray ? (@$result) : $result;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
313 }
314  
315 sub path {
316 4 ▶ my ($self, $path) = @_;
Subroutine path: called CC=2 SCAR=6.9
Pod documented
317  
318 4 my @path = CORE::grep(/./, CORE::split(/\W/, $path));
319  
320 4 ▶ return wantarray ? ($self->find(@path)) : $self->find(@path);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 3 4
321 }
322  
323 sub part {
324 2 ▶ my ($self, $code) = @_;
Subroutine part: called CC=4 SCAR=13.9
Pod documented
325  
326 2 my $data = $self->get;
327  
328 2 my $results = [[], []];
329  
330 2 ▶ for (my $i = 0; $i < @$data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$data) 18 2 20
331 18 my $index = $i;
332 18 my $value = $data->[$i];
333 18 local $_ = $value;
334 18 my $result = $code->($index, $value);
335 18 ▶ my $slot = $result ? $$results[0] : $$results[1];
Branch: 1 branch
BranchTrueFalseTotal
$result ? : 8 10 18
336  
337 18 CORE::push(@$slot, $value);
338 }
339  
340 2 ▶ return wantarray ? (@$results) : $results;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
341 }
342  
343 sub pop {
344 1 ▶ my ($self) = @_;
Subroutine pop: called CC=1 SCAR=0.0
Pod documented
345  
346 1 my $data = $self->get;
347  
348 1 return CORE::pop(@$data);
349 }
350  
351 sub push {
352 1 ▶ my ($self, @args) = @_;
Subroutine push: called CC=1 SCAR=0.0
Pod documented
353  
354 1 my $data = $self->get;
355  
356 1 CORE::push(@$data, @args);
357  
358 1 return $data;
359 }
360  
361 sub random {
362 1 ▶ my ($self) = @_;
Subroutine random: called CC=1 SCAR=0.0
Pod documented
363  
364 1 my $data = $self->get;
365  
366 1 return @$data[rand($#{$data}+1)];
367 }
368  
369 sub reverse {
370 1 ▶ my ($self) = @_;
Subroutine reverse: called CC=1 SCAR=0.0
Pod documented
371  
372 1 my $data = $self->get;
373  
374 1 return [CORE::reverse(@$data)];
375 }
376  
377 sub rotate {
378 1 ▶ my ($self) = @_;
Subroutine rotate: called CC=1 SCAR=0.0
Pod documented
379  
380 1 my $data = $self->get;
381  
382 1 CORE::push(@$data, CORE::shift(@$data));
383  
384 1 return $data;
385 }
386  
387 sub rsort {
388 1 ▶ my ($self) = @_;
Subroutine rsort: called CC=1 SCAR=0.0
Pod documented
389  
390 1 my $data = $self->get;
391  
392 1 return [CORE::sort { $b cmp $a } @$data];
393 }
394  
395 sub set {
396 0 ▶ my ($self, @args) = @_;
Subroutine set: not called CC=2 SCAR=17.9
Pod undocumented
397  
398 0 ▶ return $self->value if !int@args;
Branch: 1 branch
BranchTrueFalseTotal
unless int @args 0 0 0
399  
400 0 my ($index, $value) = @args;
401  
402 0 return $self->value->[$index] = $value;
403 }
404  
405 sub shift {
406 1 ▶ my ($self) = @_;
Subroutine shift: called CC=1 SCAR=0.0
Pod documented
407  
408 1 my $data = $self->get;
409  
410 1 return CORE::shift(@$data);
411 }
412  
413 sub slice {
414 1 ▶ my ($self, @args) = @_;
Subroutine slice: called CC=1 SCAR=0.0
Pod documented
415  
416 1 my $data = $self->get;
417  
418 1 return [@$data[@args]];
419 }
420  
421 sub sort {
422 1 ▶ my ($self) = @_;
Subroutine sort: called CC=1 SCAR=0.0
Pod documented
423  
424 1 my $data = $self->get;
425  
426 1 return [CORE::sort { $a cmp $b } @$data];
427 }
428  
429 sub unique {
430 1 ▶ my ($self) = @_;
Subroutine unique: called CC=1 SCAR=0.0
Pod documented
431  
432 1 my $data = $self->get;
433  
434 1 my %seen;
435 1 return [CORE::grep { not $seen{$_}++ } @$data];
436 }
437  
438 sub unshift {
439 1 ▶ my ($self, @args) = @_;
Subroutine unshift: called CC=1 SCAR=0.0
Pod documented
440  
441 1 my $data = $self->get;
442  
443 1 CORE::unshift(@$data, @args);
444  
445 1 return $data;
446 }
447  
448 15 1;
449  
450  
451  
452 =head1 NAME
453  
454 Venus::Array - Array Class
455  
456 =cut
457  
458 =head1 ABSTRACT
459  
460 Array Class for Perl 5
461  
462 =cut
463  
464 =head1 SYNOPSIS
465  
466 package main;
467  
468 use Venus::Array;
469  
470 my $array = Venus::Array->new([1..9]);
471  
472 # $array->random;
473  
474 =cut
475  
476 =head1 DESCRIPTION
477  
478 This package provides methods for manipulating array data.
479  
480 =cut
481  
482 =head1 INHERITS
483  
484 This package inherits behaviors from:
485  
486 L<Venus::Kind::Value>
487  
488 =cut
489  
490 =head1 INTEGRATES
491  
492 This package integrates behaviors from:
493  
494 L<Venus::Role::Mappable>
495  
496 =cut
497  
498 =head1 METHODS
499  
500 This package provides the following methods:
501  
502 =cut
503  
504 =head2 all
505  
506 all(CodeRef $code) (Bool)
507  
508 The all method returns true if the callback returns true for all of the
509 elements.
510  
511 I<Since C<0.01>>
512  
513 =over 4
514  
515 =item all example 1
516  
517 # given: synopsis;
518  
519 my $all = $array->all(sub {
520 $_ > 0;
521 });
522  
523 # 1
524  
525 =back
526  
527 =over 4
528  
529 =item all example 2
530  
531 # given: synopsis;
532  
533 my $all = $array->all(sub {
534 my ($key, $value) = @_;
535  
536 $value > 0;
537 });
538  
539 # 1
540  
541 =back
542  
543 =cut
544  
545 =head2 any
546  
547 any(CodeRef $code) (Bool)
548  
549 The any method returns true if the callback returns true for any of the
550 elements.
551  
552 I<Since C<0.01>>
553  
554 =over 4
555  
556 =item any example 1
557  
558 # given: synopsis;
559  
560 my $any = $array->any(sub {
561 $_ > 4;
562 });
563  
564 =back
565  
566 =over 4
567  
568 =item any example 2
569  
570 # given: synopsis;
571  
572 my $any = $array->any(sub {
573 my ($key, $value) = @_;
574  
575 $value > 4;
576 });
577  
578 =back
579  
580 =cut
581  
582 =head2 cast
583  
584 cast(Str $kind) (Object | Undef)
585  
586 The cast method converts L<"value"|Venus::Kind::Value> objects between
587 different I<"value"> object types, based on the name of the type provided. This
588 method will return C<undef> if the invocant is not a L<Venus::Kind::Value>.
589  
590 I<Since C<0.08>>
591  
592 =over 4
593  
594 =item cast example 1
595  
596 package main;
597  
598 use Venus::Array;
599  
600 my $array = Venus::Array->new;
601  
602 my $cast = $array->cast('array');
603  
604 # bless({ value => [] }, "Venus::Array")
605  
606 =back
607  
608 =over 4
609  
610 =item cast example 2
611  
612 package main;
613  
614 use Venus::Array;
615  
616 my $array = Venus::Array->new;
617  
618 my $cast = $array->cast('boolean');
619  
620 # bless({ value => 1 }, "Venus::Boolean")
621  
622 =back
623  
624 =over 4
625  
626 =item cast example 3
627  
628 package main;
629  
630 use Venus::Array;
631  
632 my $array = Venus::Array->new;
633  
634 my $cast = $array->cast('code');
635  
636 # bless({ value => sub { ... } }, "Venus::Code")
637  
638 =back
639  
640 =over 4
641  
642 =item cast example 4
643  
644 package main;
645  
646 use Venus::Array;
647  
648 my $array = Venus::Array->new;
649  
650 my $cast = $array->cast('float');
651  
652 # bless({ value => "1.0" }, "Venus::Float")
653  
654 =back
655  
656 =over 4
657  
658 =item cast example 5
659  
660 package main;
661  
662 use Venus::Array;
663  
664 my $array = Venus::Array->new;
665  
666 my $cast = $array->cast('hash');
667  
668 # bless({ value => {} }, "Venus::Hash")
669  
670 =back
671  
672 =over 4
673  
674 =item cast example 6
675  
676 package main;
677  
678 use Venus::Array;
679  
680 my $array = Venus::Array->new;
681  
682 my $cast = $array->cast('number');
683  
684 # bless({ value => 2 }, "Venus::Number")
685  
686 =back
687  
688 =over 4
689  
690 =item cast example 7
691  
692 package main;
693  
694 use Venus::Array;
695  
696 my $array = Venus::Array->new;
697  
698 my $cast = $array->cast('regexp');
699  
700 # bless({ value => qr/(?^u:\[\])/ }, "Venus::Regexp")
701  
702 =back
703  
704 =over 4
705  
706 =item cast example 8
707  
708 package main;
709  
710 use Venus::Array;
711  
712 my $array = Venus::Array->new;
713  
714 my $cast = $array->cast('scalar');
715  
716 # bless({ value => \[] }, "Venus::Scalar")
717  
718 =back
719  
720 =over 4
721  
722 =item cast example 9
723  
724 package main;
725  
726 use Venus::Array;
727  
728 my $array = Venus::Array->new;
729  
730 my $cast = $array->cast('string');
731  
732 # bless({ value => "[]" }, "Venus::String")
733  
734 =back
735  
736 =over 4
737  
738 =item cast example 10
739  
740 package main;
741  
742 use Venus::Array;
743  
744 my $array = Venus::Array->new;
745  
746 my $cast = $array->cast('undef');
747  
748 # bless({ value => undef }, "Venus::Undef")
749  
750 =back
751  
752 =cut
753  
754 =head2 count
755  
756 count() (Int)
757  
758 The count method returns the number of elements within the array.
759  
760 I<Since C<0.01>>
761  
762 =over 4
763  
764 =item count example 1
765  
766 # given: synopsis;
767  
768 my $count = $array->count;
769  
770 # 9
771  
772 =back
773  
774 =cut
775  
776 =head2 default
777  
778 default() (ArrayRef)
779  
780 The default method returns the default value, i.e. C<[]>.
781  
782 I<Since C<0.01>>
783  
784 =over 4
785  
786 =item default example 1
787  
788 # given: synopsis;
789  
790 my $default = $array->default;
791  
792 # []
793  
794 =back
795  
796 =cut
797  
798 =head2 delete
799  
800 delete(Int $index) (Any)
801  
802 The delete method returns the value of the element at the index specified after
803 removing it from the array.
804  
805 I<Since C<0.01>>
806  
807 =over 4
808  
809 =item delete example 1
810  
811 # given: synopsis;
812  
813 my $delete = $array->delete(2);
814  
815 # 3
816  
817 =back
818  
819 =cut
820  
821 =head2 each
822  
823 each(CodeRef $code) (ArrayRef)
824  
825 The each method executes a callback for each element in the array passing the
826 index and value as arguments. This method can return a list of values in
827 list-context.
828  
829 I<Since C<0.01>>
830  
831 =over 4
832  
833 =item each example 1
834  
835 # given: synopsis;
836  
837 my $each = $array->each(sub {
838 [$_]
839 });
840  
841 # [[1], [2], [3], [4], [5], [6], [7], [8], [9]]
842  
843 =back
844  
845 =over 4
846  
847 =item each example 2
848  
849 # given: synopsis;
850  
851 my $each = $array->each(sub {
852 my ($key, $value) = @_;
853  
854 [$key, $value]
855 });
856  
857 # [
858 # [0, 1],
859 # [1, 2],
860 # [2, 3],
861 # [3, 4],
862 # [4, 5],
863 # [5, 6],
864 # [6, 7],
865 # [7, 8],
866 # [8, 9],
867 # ]
868  
869 =back
870  
871 =cut
872  
873 =head2 empty
874  
875 empty() (Array)
876  
877 The empty method drops all elements from the array.
878  
879 I<Since C<0.01>>
880  
881 =over 4
882  
883 =item empty example 1
884  
885 # given: synopsis;
886  
887 my $empty = $array->empty;
888  
889 # bless({ value => [] }, "Venus::Array")
890  
891 =back
892  
893 =cut
894  
895 =head2 eq
896  
897 eq(Any $arg) (Bool)
898  
899 The eq method performs an I<"equals"> operation using the argument provided.
900  
901 I<Since C<0.08>>
902  
903 =over 4
904  
905 =item eq example 1
906  
907 package main;
908  
909 use Venus::Array;
910  
911 my $lvalue = Venus::Array->new;
912 my $rvalue = Venus::Array->new;
913  
914 my $result = $lvalue->eq($rvalue);
915  
916 # 1
917  
918 =back
919  
920 =over 4
921  
922 =item eq example 2
923  
924 package main;
925  
926 use Venus::Array;
927 use Venus::Code;
928  
929 my $lvalue = Venus::Array->new;
930 my $rvalue = Venus::Code->new;
931  
932 my $result = $lvalue->eq($rvalue);
933  
934 # 0
935  
936 =back
937  
938 =over 4
939  
940 =item eq example 3
941  
942 package main;
943  
944 use Venus::Array;
945 use Venus::Float;
946  
947 my $lvalue = Venus::Array->new;
948 my $rvalue = Venus::Float->new;
949  
950 my $result = $lvalue->eq($rvalue);
951  
952 # 0
953  
954 =back
955  
956 =over 4
957  
958 =item eq example 4
959  
960 package main;
961  
962 use Venus::Array;
963 use Venus::Hash;
964  
965 my $lvalue = Venus::Array->new;
966 my $rvalue = Venus::Hash->new;
967  
968 my $result = $lvalue->eq($rvalue);
969  
970 # 0
971  
972 =back
973  
974 =over 4
975  
976 =item eq example 5
977  
978 package main;
979  
980 use Venus::Array;
981 use Venus::Number;
982  
983 my $lvalue = Venus::Array->new;
984 my $rvalue = Venus::Number->new;
985  
986 my $result = $lvalue->eq($rvalue);
987  
988 # 0
989  
990 =back
991  
992 =over 4
993  
994 =item eq example 6
995  
996 package main;
997  
998 use Venus::Array;
999 use Venus::Regexp;
1000  
1001 my $lvalue = Venus::Array->new;
1002 my $rvalue = Venus::Regexp->new;
1003  
1004 my $result = $lvalue->eq($rvalue);
1005  
1006 # 0
1007  
1008 =back
1009  
1010 =over 4
1011  
1012 =item eq example 7
1013  
1014 package main;
1015  
1016 use Venus::Array;
1017 use Venus::Scalar;
1018  
1019 my $lvalue = Venus::Array->new;
1020 my $rvalue = Venus::Scalar->new;
1021  
1022 my $result = $lvalue->eq($rvalue);
1023  
1024 # 0
1025  
1026 =back
1027  
1028 =over 4
1029  
1030 =item eq example 8
1031  
1032 package main;
1033  
1034 use Venus::Array;
1035 use Venus::String;
1036  
1037 my $lvalue = Venus::Array->new;
1038 my $rvalue = Venus::String->new;
1039  
1040 my $result = $lvalue->eq($rvalue);
1041  
1042 # 0
1043  
1044 =back
1045  
1046 =over 4
1047  
1048 =item eq example 9
1049  
1050 package main;
1051  
1052 use Venus::Array;
1053 use Venus::Undef;
1054  
1055 my $lvalue = Venus::Array->new;
1056 my $rvalue = Venus::Undef->new;
1057  
1058 my $result = $lvalue->eq($rvalue);
1059  
1060 # 0
1061  
1062 =back
1063  
1064 =cut
1065  
1066 =head2 exists
1067  
1068 exists(Int $index) (Bool)
1069  
1070 The exists method returns true if the element at the index specified exists,
1071 otherwise it returns false.
1072  
1073 I<Since C<0.01>>
1074  
1075 =over 4
1076  
1077 =item exists example 1
1078  
1079 # given: synopsis;
1080  
1081 my $exists = $array->exists(0);
1082  
1083 # 1
1084  
1085 =back
1086  
1087 =cut
1088  
1089 =head2 find
1090  
1091 find(Str @keys) (Any)
1092  
1093 The find method traverses the data structure using the keys and indices
1094 provided, returning the value found or undef. In list-context, this method
1095 returns a tuple, i.e. the value found and boolean representing whether the
1096 match was successful.
1097  
1098 I<Since C<0.01>>
1099  
1100 =over 4
1101  
1102 =item find example 1
1103  
1104 package main;
1105  
1106 use Venus::Array;
1107  
1108 my $array = Venus::Array->new([{'foo' => {'bar' => 'baz'}}, 'bar', ['baz']]);
1109  
1110 my $find = $array->find(0, 'foo');
1111  
1112 # { bar => "baz" }
1113  
1114 =back
1115  
1116 =over 4
1117  
1118 =item find example 2
1119  
1120 package main;
1121  
1122 use Venus::Array;
1123  
1124 my $array = Venus::Array->new([{'foo' => {'bar' => 'baz'}}, 'bar', ['baz']]);
1125  
1126 my $find = $array->find(0, 'foo', 'bar');
1127  
1128 # "baz"
1129  
1130 =back
1131  
1132 =over 4
1133  
1134 =item find example 3
1135  
1136 package main;
1137  
1138 use Venus::Array;
1139  
1140 my $array = Venus::Array->new([{'foo' => {'bar' => 'baz'}}, 'bar', ['baz']]);
1141  
1142 my $find = $array->find(2, 0);
1143  
1144 # "baz"
1145  
1146 =back
1147  
1148 =cut
1149  
1150 =head2 first
1151  
1152 first() (Any)
1153  
1154 The first method returns the value of the first element.
1155  
1156 I<Since C<0.01>>
1157  
1158 =over 4
1159  
1160 =item first example 1
1161  
1162 # given: synopsis;
1163  
1164 my $first = $array->first;
1165  
1166 # 1
1167  
1168 =back
1169  
1170 =cut
1171  
1172 =head2 ge
1173  
1174 ge(Any $arg) (Bool)
1175  
1176 The ge method performs a I<"greater-than-or-equal-to"> operation using the
1177 argument provided.
1178  
1179 I<Since C<0.08>>
1180  
1181 =over 4
1182  
1183 =item ge example 1
1184  
1185 package main;
1186  
1187 use Venus::Array;
1188  
1189 my $lvalue = Venus::Array->new;
1190 my $rvalue = Venus::Array->new;
1191  
1192 my $result = $lvalue->ge($rvalue);
1193  
1194 # 1
1195  
1196 =back
1197  
1198 =over 4
1199  
1200 =item ge example 2
1201  
1202 package main;
1203  
1204 use Venus::Array;
1205 use Venus::Code;
1206  
1207 my $lvalue = Venus::Array->new;
1208 my $rvalue = Venus::Code->new;
1209  
1210 my $result = $lvalue->ge($rvalue);
1211  
1212 # 0
1213  
1214 =back
1215  
1216 =over 4
1217  
1218 =item ge example 3
1219  
1220 package main;
1221  
1222 use Venus::Array;
1223 use Venus::Float;
1224  
1225 my $lvalue = Venus::Array->new;
1226 my $rvalue = Venus::Float->new;
1227  
1228 my $result = $lvalue->ge($rvalue);
1229  
1230 # 1
1231  
1232 =back
1233  
1234 =over 4
1235  
1236 =item ge example 4
1237  
1238 package main;
1239  
1240 use Venus::Array;
1241 use Venus::Hash;
1242  
1243 my $lvalue = Venus::Array->new;
1244 my $rvalue = Venus::Hash->new;
1245  
1246 my $result = $lvalue->ge($rvalue);
1247  
1248 # 0
1249  
1250 =back
1251  
1252 =over 4
1253  
1254 =item ge example 5
1255  
1256 package main;
1257  
1258 use Venus::Array;
1259 use Venus::Number;
1260  
1261 my $lvalue = Venus::Array->new;
1262 my $rvalue = Venus::Number->new;
1263  
1264 my $result = $lvalue->ge($rvalue);
1265  
1266 # 1
1267  
1268 =back
1269  
1270 =over 4
1271  
1272 =item ge example 6
1273  
1274 package main;
1275  
1276 use Venus::Array;
1277 use Venus::Regexp;
1278  
1279 my $lvalue = Venus::Array->new;
1280 my $rvalue = Venus::Regexp->new;
1281  
1282 my $result = $lvalue->ge($rvalue);
1283  
1284 # 0
1285  
1286 =back
1287  
1288 =over 4
1289  
1290 =item ge example 7
1291  
1292 package main;
1293  
1294 use Venus::Array;
1295 use Venus::Scalar;
1296  
1297 my $lvalue = Venus::Array->new;
1298 my $rvalue = Venus::Scalar->new;
1299  
1300 my $result = $lvalue->ge($rvalue);
1301  
1302 # 0
1303  
1304 =back
1305  
1306 =over 4
1307  
1308 =item ge example 8
1309  
1310 package main;
1311  
1312 use Venus::Array;
1313 use Venus::String;
1314  
1315 my $lvalue = Venus::Array->new;
1316 my $rvalue = Venus::String->new;
1317  
1318 my $result = $lvalue->ge($rvalue);
1319  
1320 # 1
1321  
1322 =back
1323  
1324 =over 4
1325  
1326 =item ge example 9
1327  
1328 package main;
1329  
1330 use Venus::Array;
1331 use Venus::Undef;
1332  
1333 my $lvalue = Venus::Array->new;
1334 my $rvalue = Venus::Undef->new;
1335  
1336 my $result = $lvalue->ge($rvalue);
1337  
1338 # 1
1339  
1340 =back
1341  
1342 =cut
1343  
1344 =head2 gele
1345  
1346 gele(Any $arg1, Any $arg2) (Bool)
1347  
1348 The gele method performs a I<"greater-than-or-equal-to"> operation on the 1st
1349 argument, and I<"lesser-than-or-equal-to"> operation on the 2nd argument.
1350  
1351 I<Since C<0.08>>
1352  
1353 =over 4
1354  
1355 =item gele example 1
1356  
1357 package main;
1358  
1359 use Venus::Array;
1360  
1361 my $lvalue = Venus::Array->new;
1362 my $rvalue = Venus::Array->new;
1363  
1364 my $result = $lvalue->gele($rvalue);
1365  
1366 # 0
1367  
1368 =back
1369  
1370 =over 4
1371  
1372 =item gele example 2
1373  
1374 package main;
1375  
1376 use Venus::Array;
1377 use Venus::Code;
1378  
1379 my $lvalue = Venus::Array->new;
1380 my $rvalue = Venus::Code->new;
1381  
1382 my $result = $lvalue->gele($rvalue);
1383  
1384 # 0
1385  
1386 =back
1387  
1388 =over 4
1389  
1390 =item gele example 3
1391  
1392 package main;
1393  
1394 use Venus::Array;
1395 use Venus::Float;
1396  
1397 my $lvalue = Venus::Array->new;
1398 my $rvalue = Venus::Float->new;
1399  
1400 my $result = $lvalue->gele($rvalue);
1401  
1402 # 0
1403  
1404 =back
1405  
1406 =over 4
1407  
1408 =item gele example 4
1409  
1410 package main;
1411  
1412 use Venus::Array;
1413 use Venus::Hash;
1414  
1415 my $lvalue = Venus::Array->new;
1416 my $rvalue = Venus::Hash->new;
1417  
1418 my $result = $lvalue->gele($rvalue);
1419  
1420 # 0
1421  
1422 =back
1423  
1424 =over 4
1425  
1426 =item gele example 5
1427  
1428 package main;
1429  
1430 use Venus::Array;
1431 use Venus::Number;
1432  
1433 my $lvalue = Venus::Array->new;
1434 my $rvalue = Venus::Number->new;
1435  
1436 my $result = $lvalue->gele($rvalue);
1437  
1438 # 0
1439  
1440 =back
1441  
1442 =over 4
1443  
1444 =item gele example 6
1445  
1446 package main;
1447  
1448 use Venus::Array;
1449 use Venus::Regexp;
1450  
1451 my $lvalue = Venus::Array->new;
1452 my $rvalue = Venus::Regexp->new;
1453  
1454 my $result = $lvalue->gele($rvalue);
1455  
1456 # 0
1457  
1458 =back
1459  
1460 =over 4
1461  
1462 =item gele example 7
1463  
1464 package main;
1465  
1466 use Venus::Array;
1467 use Venus::Scalar;
1468  
1469 my $lvalue = Venus::Array->new;
1470 my $rvalue = Venus::Scalar->new;
1471  
1472 my $result = $lvalue->gele($rvalue);
1473  
1474 # 0
1475  
1476 =back
1477  
1478 =over 4
1479  
1480 =item gele example 8
1481  
1482 package main;
1483  
1484 use Venus::Array;
1485 use Venus::String;
1486  
1487 my $lvalue = Venus::Array->new;
1488 my $rvalue = Venus::String->new;
1489  
1490 my $result = $lvalue->gele($rvalue);
1491  
1492 # 0
1493  
1494 =back
1495  
1496 =over 4
1497  
1498 =item gele example 9
1499  
1500 package main;
1501  
1502 use Venus::Array;
1503 use Venus::Undef;
1504  
1505 my $lvalue = Venus::Array->new;
1506 my $rvalue = Venus::Undef->new;
1507  
1508 my $result = $lvalue->gele($rvalue);
1509  
1510 # 0
1511  
1512 =back
1513  
1514 =cut
1515  
1516 =head2 grep
1517  
1518 grep(CodeRef $code) (ArrayRef)
1519  
1520 The grep method executes a callback for each element in the array passing the
1521 value as an argument, returning a new array reference containing the elements
1522 for which the returned true. This method can return a list of values in
1523 list-context.
1524  
1525 I<Since C<0.01>>
1526  
1527 =over 4
1528  
1529 =item grep example 1
1530  
1531 # given: synopsis;
1532  
1533 my $grep = $array->grep(sub {
1534 $_ > 3
1535 });
1536  
1537 # [4..9]
1538  
1539 =back
1540  
1541 =over 4
1542  
1543 =item grep example 2
1544  
1545 # given: synopsis;
1546  
1547 my $grep = $array->grep(sub {
1548 my ($key, $value) = @_;
1549  
1550 $value > 3
1551 });
1552  
1553 # [4..9]
1554  
1555 =back
1556  
1557 =cut
1558  
1559 =head2 gt
1560  
1561 gt(Any $arg) (Bool)
1562  
1563 The gt method performs a I<"greater-than"> operation using the argument provided.
1564  
1565 I<Since C<0.08>>
1566  
1567 =over 4
1568  
1569 =item gt example 1
1570  
1571 package main;
1572  
1573 use Venus::Array;
1574  
1575 my $lvalue = Venus::Array->new;
1576 my $rvalue = Venus::Array->new;
1577  
1578 my $result = $lvalue->gt($rvalue);
1579  
1580 # 0
1581  
1582 =back
1583  
1584 =over 4
1585  
1586 =item gt example 2
1587  
1588 package main;
1589  
1590 use Venus::Array;
1591 use Venus::Code;
1592  
1593 my $lvalue = Venus::Array->new;
1594 my $rvalue = Venus::Code->new;
1595  
1596 my $result = $lvalue->gt($rvalue);
1597  
1598 # 0
1599  
1600 =back
1601  
1602 =over 4
1603  
1604 =item gt example 3
1605  
1606 package main;
1607  
1608 use Venus::Array;
1609 use Venus::Float;
1610  
1611 my $lvalue = Venus::Array->new;
1612 my $rvalue = Venus::Float->new;
1613  
1614 my $result = $lvalue->gt($rvalue);
1615  
1616 # 1
1617  
1618 =back
1619  
1620 =over 4
1621  
1622 =item gt example 4
1623  
1624 package main;
1625  
1626 use Venus::Array;
1627 use Venus::Hash;
1628  
1629 my $lvalue = Venus::Array->new;
1630 my $rvalue = Venus::Hash->new;
1631  
1632 my $result = $lvalue->gt($rvalue);
1633  
1634 # 0
1635  
1636 =back
1637  
1638 =over 4
1639  
1640 =item gt example 5
1641  
1642 package main;
1643  
1644 use Venus::Array;
1645 use Venus::Number;
1646  
1647 my $lvalue = Venus::Array->new;
1648 my $rvalue = Venus::Number->new;
1649  
1650 my $result = $lvalue->gt($rvalue);
1651  
1652 # 1
1653  
1654 =back
1655  
1656 =over 4
1657  
1658 =item gt example 6
1659  
1660 package main;
1661  
1662 use Venus::Array;
1663 use Venus::Regexp;
1664  
1665 my $lvalue = Venus::Array->new;
1666 my $rvalue = Venus::Regexp->new;
1667  
1668 my $result = $lvalue->gt($rvalue);
1669  
1670 # 0
1671  
1672 =back
1673  
1674 =over 4
1675  
1676 =item gt example 7
1677  
1678 package main;
1679  
1680 use Venus::Array;
1681 use Venus::Scalar;
1682  
1683 my $lvalue = Venus::Array->new;
1684 my $rvalue = Venus::Scalar->new;
1685  
1686 my $result = $lvalue->gt($rvalue);
1687  
1688 # 0
1689  
1690 =back
1691  
1692 =over 4
1693  
1694 =item gt example 8
1695  
1696 package main;
1697  
1698 use Venus::Array;
1699 use Venus::String;
1700  
1701 my $lvalue = Venus::Array->new;
1702 my $rvalue = Venus::String->new;
1703  
1704 my $result = $lvalue->gt($rvalue);
1705  
1706 # 1
1707  
1708 =back
1709  
1710 =over 4
1711  
1712 =item gt example 9
1713  
1714 package main;
1715  
1716 use Venus::Array;
1717 use Venus::Undef;
1718  
1719 my $lvalue = Venus::Array->new;
1720 my $rvalue = Venus::Undef->new;
1721  
1722 my $result = $lvalue->gt($rvalue);
1723  
1724 # 1
1725  
1726 =back
1727  
1728 =cut
1729  
1730 =head2 gtlt
1731  
1732 gtlt(Any $arg1, Any $arg2) (Bool)
1733  
1734 The gtlt method performs a I<"greater-than"> operation on the 1st argument, and
1735 I<"lesser-than"> operation on the 2nd argument.
1736  
1737 I<Since C<0.08>>
1738  
1739 =over 4
1740  
1741 =item gtlt example 1
1742  
1743 package main;
1744  
1745 use Venus::Array;
1746  
1747 my $lvalue = Venus::Array->new;
1748 my $rvalue = Venus::Array->new;
1749  
1750 my $result = $lvalue->gtlt($rvalue);
1751  
1752 # 0
1753  
1754 =back
1755  
1756 =over 4
1757  
1758 =item gtlt example 2
1759  
1760 package main;
1761  
1762 use Venus::Array;
1763 use Venus::Code;
1764  
1765 my $lvalue = Venus::Array->new;
1766 my $rvalue = Venus::Code->new;
1767  
1768 my $result = $lvalue->gtlt($rvalue);
1769  
1770 # 0
1771  
1772 =back
1773  
1774 =over 4
1775  
1776 =item gtlt example 3
1777  
1778 package main;
1779  
1780 use Venus::Array;
1781 use Venus::Float;
1782  
1783 my $lvalue = Venus::Array->new;
1784 my $rvalue = Venus::Float->new;
1785  
1786 my $result = $lvalue->gtlt($rvalue);
1787  
1788 # 0
1789  
1790 =back
1791  
1792 =over 4
1793  
1794 =item gtlt example 4
1795  
1796 package main;
1797  
1798 use Venus::Array;
1799 use Venus::Hash;
1800  
1801 my $lvalue = Venus::Array->new;
1802 my $rvalue = Venus::Hash->new;
1803  
1804 my $result = $lvalue->gtlt($rvalue);
1805  
1806 # 0
1807  
1808 =back
1809  
1810 =over 4
1811  
1812 =item gtlt example 5
1813  
1814 package main;
1815  
1816 use Venus::Array;
1817 use Venus::Number;
1818  
1819 my $lvalue = Venus::Array->new;
1820 my $rvalue = Venus::Number->new;
1821  
1822 my $result = $lvalue->gtlt($rvalue);
1823  
1824 # 0
1825  
1826 =back
1827  
1828 =over 4
1829  
1830 =item gtlt example 6
1831  
1832 package main;
1833  
1834 use Venus::Array;
1835 use Venus::Regexp;
1836  
1837 my $lvalue = Venus::Array->new;
1838 my $rvalue = Venus::Regexp->new;
1839  
1840 my $result = $lvalue->gtlt($rvalue);
1841  
1842 # 0
1843  
1844 =back
1845  
1846 =over 4
1847  
1848 =item gtlt example 7
1849  
1850 package main;
1851  
1852 use Venus::Array;
1853 use Venus::Scalar;
1854  
1855 my $lvalue = Venus::Array->new;
1856 my $rvalue = Venus::Scalar->new;
1857  
1858 my $result = $lvalue->gtlt($rvalue);
1859  
1860 # 0
1861  
1862 =back
1863  
1864 =over 4
1865  
1866 =item gtlt example 8
1867  
1868 package main;
1869  
1870 use Venus::Array;
1871 use Venus::String;
1872  
1873 my $lvalue = Venus::Array->new;
1874 my $rvalue = Venus::String->new;
1875  
1876 my $result = $lvalue->gtlt($rvalue);
1877  
1878 # 0
1879  
1880 =back
1881  
1882 =over 4
1883  
1884 =item gtlt example 9
1885  
1886 package main;
1887  
1888 use Venus::Array;
1889 use Venus::Undef;
1890  
1891 my $lvalue = Venus::Array->new;
1892 my $rvalue = Venus::Undef->new;
1893  
1894 my $result = $lvalue->gtlt($rvalue);
1895  
1896 # 0
1897  
1898 =back
1899  
1900 =cut
1901  
1902 =head2 iterator
1903  
1904 iterator() (CodeRef)
1905  
1906 The iterator method returns a code reference which can be used to iterate over
1907 the array. Each time the iterator is executed it will return the next element
1908 in the array until all elements have been seen, at which point the iterator
1909 will return an undefined value. This method can return a tuple with the key and
1910 value in list-context.
1911  
1912 I<Since C<0.01>>
1913  
1914 =over 4
1915  
1916 =item iterator example 1
1917  
1918 # given: synopsis;
1919  
1920 my $iterator = $array->iterator;
1921  
1922 # sub { ... }
1923  
1924 # while (my $value = $iterator->()) {
1925 # say $value; # 1
1926 # }
1927  
1928 =back
1929  
1930 =over 4
1931  
1932 =item iterator example 2
1933  
1934 # given: synopsis;
1935  
1936 my $iterator = $array->iterator;
1937  
1938 # sub { ... }
1939  
1940 # while (grep defined, my ($key, $value) = $iterator->()) {
1941 # say $value; # 1
1942 # }
1943  
1944 =back
1945  
1946 =cut
1947  
1948 =head2 join
1949  
1950 join(Str $seperator) (Str)
1951  
1952 The join method returns a string consisting of all the elements in the array
1953 joined by the join-string specified by the argument. Note: If the argument is
1954 omitted, an empty string will be used as the join-string.
1955  
1956 I<Since C<0.01>>
1957  
1958 =over 4
1959  
1960 =item join example 1
1961  
1962 # given: synopsis;
1963  
1964 my $join = $array->join;
1965  
1966 # 123456789
1967  
1968 =back
1969  
1970 =over 4
1971  
1972 =item join example 2
1973  
1974 # given: synopsis;
1975  
1976 my $join = $array->join(', ');
1977  
1978 # "1, 2, 3, 4, 5, 6, 7, 8, 9"
1979  
1980 =back
1981  
1982 =cut
1983  
1984 =head2 keyed
1985  
1986 keyed(Str @keys) (HashRef)
1987  
1988 The keyed method returns a hash reference where the arguments become the keys,
1989 and the elements of the array become the values.
1990  
1991 I<Since C<0.01>>
1992  
1993 =over 4
1994  
1995 =item keyed example 1
1996  
1997 package main;
1998  
1999 use Venus::Array;
2000  
2001 my $array = Venus::Array->new([1..4]);
2002  
2003 my $keyed = $array->keyed('a'..'d');
2004  
2005 # { a => 1, b => 2, c => 3, d => 4 }
2006  
2007 =back
2008  
2009 =cut
2010  
2011 =head2 keys
2012  
2013 keys() (ArrayRef)
2014  
2015 The keys method returns an array reference consisting of the indicies of the
2016 array.
2017  
2018 I<Since C<0.01>>
2019  
2020 =over 4
2021  
2022 =item keys example 1
2023  
2024 # given: synopsis;
2025  
2026 my $keys = $array->keys;
2027  
2028 # [0..8]
2029  
2030 =back
2031  
2032 =cut
2033  
2034 =head2 last
2035  
2036 last() (Any)
2037  
2038 The last method returns the value of the last element in the array.
2039  
2040 I<Since C<0.01>>
2041  
2042 =over 4
2043  
2044 =item last example 1
2045  
2046 # given: synopsis;
2047  
2048 my $last = $array->last;
2049  
2050 # 9
2051  
2052 =back
2053  
2054 =cut
2055  
2056 =head2 le
2057  
2058 le(Any $arg) (Bool)
2059  
2060 The le method performs a I<"lesser-than-or-equal-to"> operation using the
2061 argument provided.
2062  
2063 I<Since C<0.08>>
2064  
2065 =over 4
2066  
2067 =item le example 1
2068  
2069 package main;
2070  
2071 use Venus::Array;
2072  
2073 my $lvalue = Venus::Array->new;
2074 my $rvalue = Venus::Array->new;
2075  
2076 my $result = $lvalue->le($rvalue);
2077  
2078 # 1
2079  
2080 =back
2081  
2082 =over 4
2083  
2084 =item le example 2
2085  
2086 package main;
2087  
2088 use Venus::Array;
2089 use Venus::Code;
2090  
2091 my $lvalue = Venus::Array->new;
2092 my $rvalue = Venus::Code->new;
2093  
2094 my $result = $lvalue->le($rvalue);
2095  
2096 # 1
2097  
2098 =back
2099  
2100 =over 4
2101  
2102 =item le example 3
2103  
2104 package main;
2105  
2106 use Venus::Array;
2107 use Venus::Float;
2108  
2109 my $lvalue = Venus::Array->new;
2110 my $rvalue = Venus::Float->new;
2111  
2112 my $result = $lvalue->le($rvalue);
2113  
2114 # 0
2115  
2116 =back
2117  
2118 =over 4
2119  
2120 =item le example 4
2121  
2122 package main;
2123  
2124 use Venus::Array;
2125 use Venus::Hash;
2126  
2127 my $lvalue = Venus::Array->new;
2128 my $rvalue = Venus::Hash->new;
2129  
2130 my $result = $lvalue->le($rvalue);
2131  
2132 # 0
2133  
2134 =back
2135  
2136 =over 4
2137  
2138 =item le example 5
2139  
2140 package main;
2141  
2142 use Venus::Array;
2143 use Venus::Number;
2144  
2145 my $lvalue = Venus::Array->new;
2146 my $rvalue = Venus::Number->new;
2147  
2148 my $result = $lvalue->le($rvalue);
2149  
2150 # 0
2151  
2152 =back
2153  
2154 =over 4
2155  
2156 =item le example 6
2157  
2158 package main;
2159  
2160 use Venus::Array;
2161 use Venus::Regexp;
2162  
2163 my $lvalue = Venus::Array->new;
2164 my $rvalue = Venus::Regexp->new;
2165  
2166 my $result = $lvalue->le($rvalue);
2167  
2168 # 1
2169  
2170 =back
2171  
2172 =over 4
2173  
2174 =item le example 7
2175  
2176 package main;
2177  
2178 use Venus::Array;
2179 use Venus::Scalar;
2180  
2181 my $lvalue = Venus::Array->new;
2182 my $rvalue = Venus::Scalar->new;
2183  
2184 my $result = $lvalue->le($rvalue);
2185  
2186 # 0
2187  
2188 =back
2189  
2190 =over 4
2191  
2192 =item le example 8
2193  
2194 package main;
2195  
2196 use Venus::Array;
2197 use Venus::String;
2198  
2199 my $lvalue = Venus::Array->new;
2200 my $rvalue = Venus::String->new;
2201  
2202 my $result = $lvalue->le($rvalue);
2203  
2204 # 0
2205  
2206 =back
2207  
2208 =over 4
2209  
2210 =item le example 9
2211  
2212 package main;
2213  
2214 use Venus::Array;
2215 use Venus::Undef;
2216  
2217 my $lvalue = Venus::Array->new;
2218 my $rvalue = Venus::Undef->new;
2219  
2220 my $result = $lvalue->le($rvalue);
2221  
2222 # 0
2223  
2224 =back
2225  
2226 =cut
2227  
2228 =head2 length
2229  
2230 length() (Int)
2231  
2232 The length method returns the number of elements within the array, and is an
2233 alias for the L</count> method.
2234  
2235 I<Since C<0.08>>
2236  
2237 =over 4
2238  
2239 =item length example 1
2240  
2241 # given: synopsis;
2242  
2243 my $length = $array->length;
2244  
2245 # 9
2246  
2247 =back
2248  
2249 =cut
2250  
2251 =head2 list
2252  
2253 list() (Any)
2254  
2255 The list method returns a shallow copy of the underlying array reference as an
2256 array reference.
2257  
2258 I<Since C<0.01>>
2259  
2260 =over 4
2261  
2262 =item list example 1
2263  
2264 # given: synopsis;
2265  
2266 my $list = $array->list;
2267  
2268 # 9
2269  
2270 =back
2271  
2272 =over 4
2273  
2274 =item list example 2
2275  
2276 # given: synopsis;
2277  
2278 my @list = $array->list;
2279  
2280 # (1..9)
2281  
2282 =back
2283  
2284 =cut
2285  
2286 =head2 lt
2287  
2288 lt(Any $arg) (Bool)
2289  
2290 The lt method performs a I<"lesser-than"> operation using the argument provided.
2291  
2292 I<Since C<0.08>>
2293  
2294 =over 4
2295  
2296 =item lt example 1
2297  
2298 package main;
2299  
2300 use Venus::Array;
2301  
2302 my $lvalue = Venus::Array->new;
2303 my $rvalue = Venus::Array->new;
2304  
2305 my $result = $lvalue->lt($rvalue);
2306  
2307 # 0
2308  
2309 =back
2310  
2311 =over 4
2312  
2313 =item lt example 2
2314  
2315 package main;
2316  
2317 use Venus::Array;
2318 use Venus::Code;
2319  
2320 my $lvalue = Venus::Array->new;
2321 my $rvalue = Venus::Code->new;
2322  
2323 my $result = $lvalue->lt($rvalue);
2324  
2325 # 1
2326  
2327 =back
2328  
2329 =over 4
2330  
2331 =item lt example 3
2332  
2333 package main;
2334  
2335 use Venus::Array;
2336 use Venus::Float;
2337  
2338 my $lvalue = Venus::Array->new;
2339 my $rvalue = Venus::Float->new;
2340  
2341 my $result = $lvalue->lt($rvalue);
2342  
2343 # 0
2344  
2345 =back
2346  
2347 =over 4
2348  
2349 =item lt example 4
2350  
2351 package main;
2352  
2353 use Venus::Array;
2354 use Venus::Hash;
2355  
2356 my $lvalue = Venus::Array->new;
2357 my $rvalue = Venus::Hash->new;
2358  
2359 my $result = $lvalue->lt($rvalue);
2360  
2361 # 0
2362  
2363 =back
2364  
2365 =over 4
2366  
2367 =item lt example 5
2368  
2369 package main;
2370  
2371 use Venus::Array;
2372 use Venus::Number;
2373  
2374 my $lvalue = Venus::Array->new;
2375 my $rvalue = Venus::Number->new;
2376  
2377 my $result = $lvalue->lt($rvalue);
2378  
2379 # 0
2380  
2381 =back
2382  
2383 =over 4
2384  
2385 =item lt example 6
2386  
2387 package main;
2388  
2389 use Venus::Array;
2390 use Venus::Regexp;
2391  
2392 my $lvalue = Venus::Array->new;
2393 my $rvalue = Venus::Regexp->new;
2394  
2395 my $result = $lvalue->lt($rvalue);
2396  
2397 # 1
2398  
2399 =back
2400  
2401 =over 4
2402  
2403 =item lt example 7
2404  
2405 package main;
2406  
2407 use Venus::Array;
2408 use Venus::Scalar;
2409  
2410 my $lvalue = Venus::Array->new;
2411 my $rvalue = Venus::Scalar->new;
2412  
2413 my $result = $lvalue->lt($rvalue);
2414  
2415 # 0
2416  
2417 =back
2418  
2419 =over 4
2420  
2421 =item lt example 8
2422  
2423 package main;
2424  
2425 use Venus::Array;
2426 use Venus::String;
2427  
2428 my $lvalue = Venus::Array->new;
2429 my $rvalue = Venus::String->new;
2430  
2431 my $result = $lvalue->lt($rvalue);
2432  
2433 # 0
2434  
2435 =back
2436  
2437 =over 4
2438  
2439 =item lt example 9
2440  
2441 package main;
2442  
2443 use Venus::Array;
2444 use Venus::Undef;
2445  
2446 my $lvalue = Venus::Array->new;
2447 my $rvalue = Venus::Undef->new;
2448  
2449 my $result = $lvalue->lt($rvalue);
2450  
2451 # 0
2452  
2453 =back
2454  
2455 =cut
2456  
2457 =head2 map
2458  
2459 map(CodeRef $code) (ArrayRef)
2460  
2461 The map method iterates over each element in the array, executing the code
2462 reference supplied in the argument, passing the routine the value at the
2463 current position in the loop and returning a new array reference containing the
2464 elements for which the argument returns a value or non-empty list. This method
2465 can return a list of values in list-context.
2466  
2467 I<Since C<0.01>>
2468  
2469 =over 4
2470  
2471 =item map example 1
2472  
2473 # given: synopsis;
2474  
2475 my $map = $array->map(sub {
2476 $_ * 2
2477 });
2478  
2479 # [2, 4, 6, 8, 10, 12, 14, 16, 18]
2480  
2481 =back
2482  
2483 =over 4
2484  
2485 =item map example 2
2486  
2487 # given: synopsis;
2488  
2489 my $map = $array->map(sub {
2490 my ($key, $value) = @_;
2491  
2492 [$key, ($value * 2)]
2493 });
2494  
2495 # [
2496 # [0, 2],
2497 # [1, 4],
2498 # [2, 6],
2499 # [3, 8],
2500 # [4, 10],
2501 # [5, 12],
2502 # [6, 14],
2503 # [7, 16],
2504 # [8, 18],
2505 # ]
2506  
2507 =back
2508  
2509 =cut
2510  
2511 =head2 ne
2512  
2513 ne(Any $arg) (Bool)
2514  
2515 The ne method performs a I<"not-equal-to"> operation using the argument provided.
2516  
2517 I<Since C<0.08>>
2518  
2519 =over 4
2520  
2521 =item ne example 1
2522  
2523 package main;
2524  
2525 use Venus::Array;
2526  
2527 my $lvalue = Venus::Array->new;
2528 my $rvalue = Venus::Array->new;
2529  
2530 my $result = $lvalue->ne($rvalue);
2531  
2532 # 0
2533  
2534 =back
2535  
2536 =over 4
2537  
2538 =item ne example 2
2539  
2540 package main;
2541  
2542 use Venus::Array;
2543 use Venus::Code;
2544  
2545 my $lvalue = Venus::Array->new;
2546 my $rvalue = Venus::Code->new;
2547  
2548 my $result = $lvalue->ne($rvalue);
2549  
2550 # 1
2551  
2552 =back
2553  
2554 =over 4
2555  
2556 =item ne example 3
2557  
2558 package main;
2559  
2560 use Venus::Array;
2561 use Venus::Float;
2562  
2563 my $lvalue = Venus::Array->new;
2564 my $rvalue = Venus::Float->new;
2565  
2566 my $result = $lvalue->ne($rvalue);
2567  
2568 # 1
2569  
2570 =back
2571  
2572 =over 4
2573  
2574 =item ne example 4
2575  
2576 package main;
2577  
2578 use Venus::Array;
2579 use Venus::Hash;
2580  
2581 my $lvalue = Venus::Array->new;
2582 my $rvalue = Venus::Hash->new;
2583  
2584 my $result = $lvalue->ne($rvalue);
2585  
2586 # 1
2587  
2588 =back
2589  
2590 =over 4
2591  
2592 =item ne example 5
2593  
2594 package main;
2595  
2596 use Venus::Array;
2597 use Venus::Number;
2598  
2599 my $lvalue = Venus::Array->new;
2600 my $rvalue = Venus::Number->new;
2601  
2602 my $result = $lvalue->ne($rvalue);
2603  
2604 # 1
2605  
2606 =back
2607  
2608 =over 4
2609  
2610 =item ne example 6
2611  
2612 package main;
2613  
2614 use Venus::Array;
2615 use Venus::Regexp;
2616  
2617 my $lvalue = Venus::Array->new;
2618 my $rvalue = Venus::Regexp->new;
2619  
2620 my $result = $lvalue->ne($rvalue);
2621  
2622 # 1
2623  
2624 =back
2625  
2626 =over 4
2627  
2628 =item ne example 7
2629  
2630 package main;
2631  
2632 use Venus::Array;
2633 use Venus::Scalar;
2634  
2635 my $lvalue = Venus::Array->new;
2636 my $rvalue = Venus::Scalar->new;
2637  
2638 my $result = $lvalue->ne($rvalue);
2639  
2640 # 1
2641  
2642 =back
2643  
2644 =over 4
2645  
2646 =item ne example 8
2647  
2648 package main;
2649  
2650 use Venus::Array;
2651 use Venus::String;
2652  
2653 my $lvalue = Venus::Array->new;
2654 my $rvalue = Venus::String->new;
2655  
2656 my $result = $lvalue->ne($rvalue);
2657  
2658 # 1
2659  
2660 =back
2661  
2662 =over 4
2663  
2664 =item ne example 9
2665  
2666 package main;
2667  
2668 use Venus::Array;
2669 use Venus::Undef;
2670  
2671 my $lvalue = Venus::Array->new;
2672 my $rvalue = Venus::Undef->new;
2673  
2674 my $result = $lvalue->ne($rvalue);
2675  
2676 # 1
2677  
2678 =back
2679  
2680 =cut
2681  
2682 =head2 none
2683  
2684 none(CodeRef $code) (Bool)
2685  
2686 The none method returns true if none of the elements in the array meet the
2687 criteria set by the operand and rvalue.
2688  
2689 I<Since C<0.01>>
2690  
2691 =over 4
2692  
2693 =item none example 1
2694  
2695 # given: synopsis;
2696  
2697 my $none = $array->none(sub {
2698 $_ < 1
2699 });
2700  
2701 # 1
2702  
2703 =back
2704  
2705 =over 4
2706  
2707 =item none example 2
2708  
2709 # given: synopsis;
2710  
2711 my $none = $array->none(sub {
2712 my ($key, $value) = @_;
2713  
2714 $value < 1
2715 });
2716  
2717 # 1
2718  
2719 =back
2720  
2721 =cut
2722  
2723 =head2 one
2724  
2725 one(CodeRef $code) (Bool)
2726  
2727 The one method returns true if only one of the elements in the array meet the
2728 criteria set by the operand and rvalue.
2729  
2730 I<Since C<0.01>>
2731  
2732 =over 4
2733  
2734 =item one example 1
2735  
2736 # given: synopsis;
2737  
2738 my $one = $array->one(sub {
2739 $_ == 1
2740 });
2741  
2742 # 1
2743  
2744 =back
2745  
2746 =over 4
2747  
2748 =item one example 2
2749  
2750 # given: synopsis;
2751  
2752 my $one = $array->one(sub {
2753 my ($key, $value) = @_;
2754  
2755 $value == 1
2756 });
2757  
2758 # 1
2759  
2760 =back
2761  
2762 =cut
2763  
2764 =head2 pairs
2765  
2766 pairs() (ArrayRef)
2767  
2768 The pairs method is an alias to the pairs_array method. This method can return
2769 a list of values in list-context.
2770  
2771 I<Since C<0.01>>
2772  
2773 =over 4
2774  
2775 =item pairs example 1
2776  
2777 # given: synopsis;
2778  
2779 my $pairs = $array->pairs;
2780  
2781 # [
2782 # [0, 1],
2783 # [1, 2],
2784 # [2, 3],
2785 # [3, 4],
2786 # [4, 5],
2787 # [5, 6],
2788 # [6, 7],
2789 # [7, 8],
2790 # [8, 9],
2791 # ]
2792  
2793 =back
2794  
2795 =cut
2796  
2797 =head2 part
2798  
2799 part(CodeRef $code) (Tuple[ArrayRef, ArrayRef])
2800  
2801 The part method iterates over each element in the array, executing the code
2802 reference supplied in the argument, using the result of the code reference to
2803 partition to array into two distinct array references. This method can return a
2804 list of values in list-context.
2805  
2806 I<Since C<0.01>>
2807  
2808 =over 4
2809  
2810 =item part example 1
2811  
2812 # given: synopsis;
2813  
2814 my $part = $array->part(sub {
2815 $_ > 5
2816 });
2817  
2818 # [[6..9], [1..5]]
2819  
2820 =back
2821  
2822 =over 4
2823  
2824 =item part example 2
2825  
2826 # given: synopsis;
2827  
2828 my $part = $array->part(sub {
2829 my ($key, $value) = @_;
2830  
2831 $value < 5
2832 });
2833  
2834 # [[1..4], [5..9]]
2835  
2836 =back
2837  
2838 =cut
2839  
2840 =head2 path
2841  
2842 path(Str $expr) (Any)
2843  
2844 The path method traverses the data structure using the path expr provided,
2845 returning the value found or undef. In list-context, this method returns a
2846 tuple, i.e. the value found and boolean representing whether the match was
2847 successful.
2848  
2849 I<Since C<0.01>>
2850  
2851 =over 4
2852  
2853 =item path example 1
2854  
2855 package main;
2856  
2857 use Venus::Array;
2858  
2859 my $array = Venus::Array->new([{'foo' => {'bar' => 'baz'}}, 'bar', ['baz']]);
2860  
2861 my $path = $array->path('/0/foo');
2862  
2863 # { bar => "baz" }
2864  
2865 =back
2866  
2867 =over 4
2868  
2869 =item path example 2
2870  
2871 package main;
2872  
2873 use Venus::Array;
2874  
2875 my $array = Venus::Array->new([{'foo' => {'bar' => 'baz'}}, 'bar', ['baz']]);
2876  
2877 my $path = $array->path('/0/foo/bar');
2878  
2879 # "baz"
2880  
2881 =back
2882  
2883 =over 4
2884  
2885 =item path example 3
2886  
2887 package main;
2888  
2889 use Venus::Array;
2890  
2891 my $array = Venus::Array->new([{'foo' => {'bar' => 'baz'}}, 'bar', ['baz']]);
2892  
2893 my $path = $array->path('/2/0');
2894  
2895 # "baz"
2896  
2897 =back
2898  
2899 =over 4
2900  
2901 =item path example 4
2902  
2903 package main;
2904  
2905 use Venus::Array;
2906  
2907 my $array = Venus::Array->new([{'foo' => {'bar' => 'baz'}}, 'bar', ['baz']]);
2908  
2909 my @path = $array->path('/3/0');
2910  
2911 # (undef, 0)
2912  
2913 =back
2914  
2915 =cut
2916  
2917 =head2 pop
2918  
2919 pop() (Any)
2920  
2921 The pop method returns the last element of the array shortening it by one.
2922 Note, this method modifies the array.
2923  
2924 I<Since C<0.01>>
2925  
2926 =over 4
2927  
2928 =item pop example 1
2929  
2930 # given: synopsis;
2931  
2932 my $pop = $array->pop;
2933  
2934 # 9
2935  
2936 =back
2937  
2938 =cut
2939  
2940 =head2 push
2941  
2942 push(Any @data) (ArrayRef)
2943  
2944 The push method appends the array by pushing the agruments onto it and returns
2945 itself.
2946  
2947 I<Since C<0.01>>
2948  
2949 =over 4
2950  
2951 =item push example 1
2952  
2953 # given: synopsis;
2954  
2955 my $push = $array->push(10);
2956  
2957 # [1..10]
2958  
2959 =back
2960  
2961 =cut
2962  
2963 =head2 random
2964  
2965 random() (Any)
2966  
2967 The random method returns a random element from the array.
2968  
2969 I<Since C<0.01>>
2970  
2971 =over 4
2972  
2973 =item random example 1
2974  
2975 # given: synopsis;
2976  
2977 my $random = $array->random;
2978  
2979 # 2
2980  
2981 # my $random = $array->random;
2982  
2983 # 1
2984  
2985 =back
2986  
2987 =cut
2988  
2989 =head2 reverse
2990  
2991 reverse() (ArrayRef)
2992  
2993 The reverse method returns an array reference containing the elements in the
2994 array in reverse order.
2995  
2996 I<Since C<0.01>>
2997  
2998 =over 4
2999  
3000 =item reverse example 1
3001  
3002 # given: synopsis;
3003  
3004 my $reverse = $array->reverse;
3005  
3006 # [9, 8, 7, 6, 5, 4, 3, 2, 1]
3007  
3008 =back
3009  
3010 =cut
3011  
3012 =head2 rotate
3013  
3014 rotate() (ArrayRef)
3015  
3016 The rotate method rotates the elements in the array such that first elements
3017 becomes the last element and the second element becomes the first element each
3018 time this method is called.
3019  
3020 I<Since C<0.01>>
3021  
3022 =over 4
3023  
3024 =item rotate example 1
3025  
3026 # given: synopsis;
3027  
3028 my $rotate = $array->rotate;
3029  
3030 # [2..9, 1]
3031  
3032 =back
3033  
3034 =cut
3035  
3036 =head2 rsort
3037  
3038 rsort() (ArrayRef)
3039  
3040 The rsort method returns an array reference containing the values in the array
3041 sorted alphanumerically in reverse.
3042  
3043 I<Since C<0.01>>
3044  
3045 =over 4
3046  
3047 =item rsort example 1
3048  
3049 # given: synopsis;
3050  
3051 my $rsort = $array->rsort;
3052  
3053 # [9, 8, 7, 6, 5, 4, 3, 2, 1]
3054  
3055 =back
3056  
3057 =cut
3058  
3059 =head2 shift
3060  
3061 shift() (Any)
3062  
3063 The shift method returns the first element of the array shortening it by one.
3064  
3065 I<Since C<0.01>>
3066  
3067 =over 4
3068  
3069 =item shift example 1
3070  
3071 # given: synopsis;
3072  
3073 my $shift = $array->shift;
3074  
3075 # 1
3076  
3077 =back
3078  
3079 =cut
3080  
3081 =head2 slice
3082  
3083 slice(Str @keys) (ArrayRef)
3084  
3085 The slice method returns a hash reference containing the elements in the array
3086 at the index(es) specified in the arguments.
3087  
3088 I<Since C<0.01>>
3089  
3090 =over 4
3091  
3092 =item slice example 1
3093  
3094 # given: synopsis;
3095  
3096 my $slice = $array->slice(2, 4);
3097  
3098 # [3, 5]
3099  
3100 =back
3101  
3102 =cut
3103  
3104 =head2 sort
3105  
3106 sort() (ArrayRef)
3107  
3108 The sort method returns an array reference containing the values in the array
3109 sorted alphanumerically.
3110  
3111 I<Since C<0.01>>
3112  
3113 =over 4
3114  
3115 =item sort example 1
3116  
3117 package main;
3118  
3119 use Venus::Array;
3120  
3121 my $array = Venus::Array->new(['d','c','b','a']);
3122  
3123 my $sort = $array->sort;
3124  
3125 # ["a".."d"]
3126  
3127 =back
3128  
3129 =cut
3130  
3131 =head2 tv
3132  
3133 tv(Any $arg) (Bool)
3134  
3135 The tv method performs a I<"type-and-value-equal-to"> operation using argument
3136 provided.
3137  
3138 I<Since C<0.08>>
3139  
3140 =over 4
3141  
3142 =item tv example 1
3143  
3144 package main;
3145  
3146 use Venus::Array;
3147  
3148 my $lvalue = Venus::Array->new;
3149 my $rvalue = Venus::Array->new;
3150  
3151 my $result = $lvalue->tv($rvalue);
3152  
3153 # 1
3154  
3155 =back
3156  
3157 =over 4
3158  
3159 =item tv example 2
3160  
3161 package main;
3162  
3163 use Venus::Array;
3164 use Venus::Code;
3165  
3166 my $lvalue = Venus::Array->new;
3167 my $rvalue = Venus::Code->new;
3168  
3169 my $result = $lvalue->tv($rvalue);
3170  
3171 # 0
3172  
3173 =back
3174  
3175 =over 4
3176  
3177 =item tv example 3
3178  
3179 package main;
3180  
3181 use Venus::Array;
3182 use Venus::Float;
3183  
3184 my $lvalue = Venus::Array->new;
3185 my $rvalue = Venus::Float->new;
3186  
3187 my $result = $lvalue->tv($rvalue);
3188  
3189 # 0
3190  
3191 =back
3192  
3193 =over 4
3194  
3195 =item tv example 4
3196  
3197 package main;
3198  
3199 use Venus::Array;
3200 use Venus::Hash;
3201  
3202 my $lvalue = Venus::Array->new;
3203 my $rvalue = Venus::Hash->new;
3204  
3205 my $result = $lvalue->tv($rvalue);
3206  
3207 # 0
3208  
3209 =back
3210  
3211 =over 4
3212  
3213 =item tv example 5
3214  
3215 package main;
3216  
3217 use Venus::Array;
3218 use Venus::Number;
3219  
3220 my $lvalue = Venus::Array->new;
3221 my $rvalue = Venus::Number->new;
3222  
3223 my $result = $lvalue->tv($rvalue);
3224  
3225 # 0
3226  
3227 =back
3228  
3229 =over 4
3230  
3231 =item tv example 6
3232  
3233 package main;
3234  
3235 use Venus::Array;
3236 use Venus::Regexp;
3237  
3238 my $lvalue = Venus::Array->new;
3239 my $rvalue = Venus::Regexp->new;
3240  
3241 my $result = $lvalue->tv($rvalue);
3242  
3243 # 0
3244  
3245 =back
3246  
3247 =over 4
3248  
3249 =item tv example 7
3250  
3251 package main;
3252  
3253 use Venus::Array;
3254 use Venus::Scalar;
3255  
3256 my $lvalue = Venus::Array->new;
3257 my $rvalue = Venus::Scalar->new;
3258  
3259 my $result = $lvalue->tv($rvalue);
3260  
3261 # 0
3262  
3263 =back
3264  
3265 =over 4
3266  
3267 =item tv example 8
3268  
3269 package main;
3270  
3271 use Venus::Array;
3272 use Venus::String;
3273  
3274 my $lvalue = Venus::Array->new;
3275 my $rvalue = Venus::String->new;
3276  
3277 my $result = $lvalue->tv($rvalue);
3278  
3279 # 0
3280  
3281 =back
3282  
3283 =over 4
3284  
3285 =item tv example 9
3286  
3287 package main;
3288  
3289 use Venus::Array;
3290 use Venus::Undef;
3291  
3292 my $lvalue = Venus::Array->new;
3293 my $rvalue = Venus::Undef->new;
3294  
3295 my $result = $lvalue->tv($rvalue);
3296  
3297 # 0
3298  
3299 =back
3300  
3301 =cut
3302  
3303 =head2 unique
3304  
3305 unique() (ArrayRef)
3306  
3307 The unique method returns an array reference consisting of the unique elements
3308 in the array.
3309  
3310 I<Since C<0.01>>
3311  
3312 =over 4
3313  
3314 =item unique example 1
3315  
3316 package main;
3317  
3318 use Venus::Array;
3319  
3320 my $array = Venus::Array->new([1,1,1,1,2,3,1]);
3321  
3322 my $unique = $array->unique;
3323  
3324 # [1, 2, 3]
3325  
3326 =back
3327  
3328 =cut
3329  
3330 =head2 unshift
3331  
3332 unshift(Any @data) (ArrayRef)
3333  
3334 The unshift method prepends the array by pushing the agruments onto it and
3335 returns itself.
3336  
3337 I<Since C<0.01>>
3338  
3339 =over 4
3340  
3341 =item unshift example 1
3342  
3343 # given: synopsis;
3344  
3345 my $unshift = $array->unshift(-2,-1,0);
3346  
3347 # [-2..9]
3348  
3349 =back
3350  
3351 =cut
« Venus/Box.pm ↑ Summary Venus/Process.pm »