Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix sliding-window routines to work on current Rakudo and Niecza.

  • Loading branch information...
commit 41c3de06d2779c3b28f3bcee24d9019aacd817a7 1 parent adf31e2
@colomon authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 lib/List/Utils.pm
View
6 lib/List/Utils.pm
@@ -1,9 +1,8 @@
module List::Utils;
sub sliding-window(@a, $n) is export {
- my $a-list = @a.iterator.list;
my @values;
- gather while defined(my $a = $a-list.shift) {
+ gather for @a -> $a {
@values.push($a);
@values.shift if +@values > $n;
take @values if +@values == $n;
@@ -11,10 +10,9 @@ sub sliding-window(@a, $n) is export {
}
sub sliding-window-wrapped(@a, $n) is export {
- my $a-list = @a.iterator.list;
my @values;
gather {
- while defined(my $a = $a-list.shift) {
+ for @a -> $a {
@values.push($a);
@values.shift if +@values > $n;
take @values if +@values == $n;
Please sign in to comment.
Something went wrong with that request. Please try again.