Permalink
Browse files

lazy implementation of List.first. colomon++

Signed-off-by: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information...
1 parent 57a1482 commit 56fad03b58505c93f3e4ba4975b077d882563bc1 @timo timo committed with moritz Jul 18, 2013
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/core/Any.pm
View
@@ -38,10 +38,8 @@ my class Any {
self.map({ $_ if $_ ~~ $test });
}
method first(Mu $test) is rw {
- for self.list {
- return $_ if $_ ~~ $test;
- }
- Nil;
+ my @results := self.grep($test);
+ @results ?? @results[0] !! Nil;
}
method join($separator = '') {

0 comments on commit 56fad03

Please sign in to comment.