@@ -32,10 +32,34 @@ the return values are accessed.
32
32
= head2 grep
33
33
34
34
multi sub grep(Mu $matcher, *@elems) returns List:D
35
- multi method grep(List:D:, Mu $matcher) returns List:D
35
+ multi method grep(List:D: Mu $matcher) returns List:D
36
36
37
37
Returns a lazy list of elements against which C < $matcher > smart-matches.
38
38
The elements are returned in the order in which they appear in the original
39
39
list.
40
40
41
+ = head2 first
42
+
43
+ multi sub first(Mu $matcher, *@elems)
44
+ multi method first(List:D: Mu $matcher)
45
+
46
+ Returns the first item of the list which smart-matches against C < $matcher > .
47
+
48
+ = head2 classify
49
+
50
+ multi sub classify(&mapper, *@values) returns Hash:D
51
+ multi method classify(List:D: &mapper) returns Hash:D
52
+
53
+ C < classify > transforms a list or array of values into a hash
54
+ representing the classification of those values according to a mapper;
55
+ each hash key represents the classification for one or more of the
56
+ incoming list values, and the corresponding hash value contains
57
+ an array of those list values classified by the mapper into the category
58
+ of the associated key. For example:
59
+
60
+ my @list = (1, 2, 3, 4);
61
+ my %h = classify { $_ % 2 ?? 'odd' !! 'even' }, @list;
62
+
63
+ Creates the hash C << { odd => [1, 3], even => [2, 4] } >> in C < %h > .
64
+
41
65
= end pod
0 commit comments