Permalink
Browse files

Move .rotor to Any

.rotor is less abour List these days, and more about iterables.
Since Any has an iterator method that does .list.iterator, we don't
actually need .rotor to live in List anymore.  This may also speed
up things, because no intermediate list is necessary anymore, e.g
when calling .rotor on a .Seq, as in @foo.map( *-42 ).rotor(4)
  • Loading branch information...
lizmat committed Jan 18, 2017
1 parent 703799e commit fd8df7f2ad509689a64b8825e1c4bb622cf7486f
Showing with 8 additions and 10 deletions.
  1. +8 −0 src/core/Any-iterable-methods.pm
  2. +0 −1 src/core/Any.pm
  3. +0 −8 src/core/List.pm
  4. +0 −1 src/core/Supply.pm
@@ -1916,6 +1916,14 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}
@found
}
proto method rotor(|) is nodal { * }
multi method rotor(Any:D: Int:D $batch, :$partial) {
Seq.new(Rakudo::Iterator.Batch(self.iterator,$batch,$partial))
}
multi method rotor(Any:D: *@cycle, :$partial) {
Seq.new(Rakudo::Iterator.Rotor(self.iterator,@cycle,$partial))
}
}
BEGIN Attribute.^compose;
View
@@ -149,7 +149,6 @@ my class Any { # declared in BOOTSTRAP
Hash.^parameterize(Any,Any).new.categorize-list($test, self.list, :&as);
}
method rotor(|c) is nodal { self.list.rotor(|c) }
method reverse() is nodal { self.list.reverse }
method combinations(|c) is nodal { self.list.combinations(|c) }
method permutations(|c) is nodal { self.list.permutations(|c) }
View
@@ -1021,14 +1021,6 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
)
}
proto method rotor(|) is nodal { * }
multi method rotor(List:D: Int:D $batch, :$partial) {
Seq.new(Rakudo::Iterator.Batch(self.iterator,$batch,$partial))
}
multi method rotor(List:D: *@cycle, :$partial) {
Seq.new(Rakudo::Iterator.Rotor(self.iterator,@cycle,$partial))
}
proto method combinations(|) is nodal {*}
multi method combinations() {
nqp::stmts(
View
@@ -766,7 +766,6 @@ my class Supply {
}
}
proto method rotor(|) {*}
multi method rotor(Supply:D $self: *@cycle, :$partial) {
my @c := @cycle.is-lazy ?? @cycle !! (@cycle xx *).flat.cache;
supply {

0 comments on commit fd8df7f

Please sign in to comment.