1#!/usr/bin/env perl
2
3# for feeding NYTProf
4
5use strict; use warnings;
6
7use Devel::Hide 'List::UtilsBy::XS';
8
9use List::Objects::WithUtils;
10
11my $arr = array 1 .. 1000;
12
13sub main {
14# bisect
15  my $pair = $arr->bisect(sub { $_ >= 500 });
16# copy
17  my $copy = $arr->copy;
18# count
19  my $count = $arr->count;
20# defined
21  1 if $arr->defined(1);
22# diff
23  array(1 .. 3)->diff([ 5,4,3,2,1 ]);
24# end
25  my $lastidx = $arr->end;
26# exists
27  1 if $arr->exists(10);
28# first_index
29  my $firstidx = $arr->first_index(sub { $_ == 10 });
30# first_where
31  my $first = $arr->first_where(sub { $_ == 10 });
32# flatten_all
33  my $flat = array([1, 2, [ 3, 4 ] ])->flatten_all;
34# flatten
35  $flat = array(1, 2, [ 3, 4, [ 5, 6 ] ])->flatten(1);
36  $flat = array(1, 2, [ 3, 4, [ 5, 6, [ 7, 8 ] ] ])->flatten(2);
37# folds
38  my $res = $arr->foldr(sub { $a + $b });
39  $res = $arr->foldl(sub { $a + $b });
40# get_or_else
41  $res = $arr->get_or_else(9999 => sub { 1 });
42# grep
43  $res = $arr->grep(sub { $_ > 500 });
44# has_any
45  1 if $arr->has_any;
46  1 if $arr->has_any(sub { $_ > 500 });
47# head
48  $res = $arr->head;
49  my ($head, $tail) = $arr->head;
50# indexes
51  $res = $arr->indexes(sub { $_ > 500 });
52# inflate
53  my $hash = array(foo => 1, bar => 2, baz => 3)->inflate;
54# intersection
55  $res = array(qw/a b c d/)->intersection([qw/c d e f/]);
56# items_after_incl
57  $res = $arr->items_after_incl(sub { $_ > 500 });
58# items_after
59  $res = $arr->items_after(sub { $_ > 500 });
60# items_before_incl
61  $res = $arr->items_before_incl(sub { $_ > 500 });
62# items_before
63  $res = $arr->items_before(sub { $_ > 500 });
64# join
65  $res = $arr->join(' ');
66# kv
67  $res = $arr->kv;
68# last_index
69  $res = $arr->last_index(sub { $_ < 400 });
70# last_where
71  $res = $arr->last_where(sub { $_ < 400 });
72# map
73  $res = $arr->map(sub { $_ + 1 });
74# mapval
75  $res = $arr->mapval(sub { $_ + 1 });
76# mesh
77  $res = array(1 .. 4)->mesh(['a' .. 'd']);
78# natatime
79  my $itr = $arr->natatime(100);
80  1 while $itr->();
81# nsect
82  $res = $arr->nsect(2);
83# nsort_by
84  $res = $arr->nsort_by(sub { $_ });
85# part
86  $res = $arr->part(sub { $_ & 1 });
87# random
88  $res = $arr->random;
89# reverse
90  $res = $arr->reverse;
91# rotate_in_place
92  $arr->rotate_in_place;
93# rotate
94  $res = $arr->rotate;
95# shuffle
96  $res = $arr->shuffle;
97# sliced
98  $res = $arr->sliced(1 .. 10);
99# sort_by
100  $res = $arr->sort_by(sub { $_ });
101# sort
102  $res = $arr->sort;
103# splice
104  $res = $arr->splice(2);
105# ssect
106  $res = $arr->ssect(3);
107# tuples
108  $res = $arr->tuples(2);
109# uniq
110  $res = array(1 .. 100, 1 .. 30)->uniq;
111# visit
112  $arr->visit(sub { $_++ });
113}
114
115
116main for 1 .. 10000;
117