Skip to content
Browse files

Fix Seq.perl to not say Seq.new(). Interim fix for Iterator.perl infi…

…nite loops.
  • Loading branch information...
1 parent 5c8257f commit d952fc4b1d052c0b2f6cce2ae2f26ab813776a61 @quester quester committed with colomon Apr 20, 2010
Showing with 15 additions and 2 deletions.
  1. +11 −2 src/core/Iterator.pm
  2. +4 −0 src/core/Seq.pm
View
13 src/core/Iterator.pm
@@ -1,6 +1,15 @@
augment class Iterator {
- multi method perl() {
- $.eager.perl;
+ multi method perl(:$limit = 40) {
+ # Doing this right is probably beyond mortal dwimmery,
+ # and even in simple cases it needs the ability to
+ # serialize code to have any hope of producing
+ # output like (1, 1, * + * ... *)
+ # rather than (1, 1, 2, 3, 5, {???} ... ???).
+ # Try to do something useful for debugging, for now.
+ my @a = self.batch($limit);
+ my $and_more = '';
+ $and_more = ', {???} ... ???' if @a == $limit;
+ '(' ~ @a.map({ $^a.perl }).join(', ') ~ $and_more ~ ')';
}
multi method elems() {
View
4 src/core/Seq.pm
@@ -88,6 +88,10 @@ augment class Seq {
multi method fmt($format = '%s', $seperator = ' ') {
self.map({ .fmt($format)}).join($seperator);
}
+
+ method perl() {
+ '(' ~ self.map({ $^a.perl }).join(', ') ~ ')';
+ }
}
multi sub sort (@x, :&by = &infix:<cmp>) { @x.sort(&by) }

0 comments on commit d952fc4

Please sign in to comment.
Something went wrong with that request. Please try again.