Skip to content

Commit

Permalink
Fix Seq.perl to not say Seq.new(). Interim fix for Iterator.perl infi…
Browse files Browse the repository at this point in the history
…nite loops.
  • Loading branch information
quester authored and colomon committed Apr 22, 2010
1 parent 5c8257f commit d952fc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions 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() {
Expand Down
4 changes: 4 additions & 0 deletions src/core/Seq.pm
Expand Up @@ -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) }
Expand Down

0 comments on commit d952fc4

Please sign in to comment.