Skip to content

Commit

Permalink
Refactor some methods in/into Iterator/Iterable.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Feb 23, 2010
1 parent b9b10eb commit 7c90f14
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
22 changes: 21 additions & 1 deletion src/core/Iterable.pm
@@ -1,5 +1,25 @@
augment class Iterable {
multi method Int() {
$.elems.Int;
}

multi method Num() {
$.elems;
}

multi method Seq() {
self.iterator.Seq;
$.iterator.Seq;
}

multi method Str() {
pir::join(' ', $.iterator.eager);
}

multi method eager() {
$.iterator.eager;
}

multi method elems() {
$.iterator.elems;
}
}
4 changes: 0 additions & 4 deletions src/core/Iterator.pm
Expand Up @@ -11,10 +11,6 @@ augment class Iterator {
Seq.new!STORE(self);
}

multi method Str() {
pir::join(' ', self.eager);
}

# TimToady suggests this should be on Cool,
# but it makes more sense to me here. Also
# should support slices, but I don't know
Expand Down
8 changes: 0 additions & 8 deletions src/core/Range.pm
Expand Up @@ -62,14 +62,6 @@ class Range is Iterable {
my $emax = $.excludes_max ?? "^" !! "";
$min ~ $emin ~ ".." ~ $emax ~ $max;
}

our Str multi method Str() {
$.iterator.Str;
}

our multi method Num() {
$.iterator.elems;
}
}

our multi sub infix:<..>($min, $max) {
Expand Down
6 changes: 0 additions & 6 deletions src/core/Seq.pm
@@ -1,12 +1,6 @@
augment class Seq {
multi method eager() { self.iterator.eager; }

method elems() { pir::set__IP(self!fill); }

method Num() { self.elems; }

method Int() { self.elems.Int; }

method Str() {
pir::join(' ', self!fill);
}
Expand Down

0 comments on commit 7c90f14

Please sign in to comment.