Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move unobe++'s Array ".perl" code to an actual Array.perl function.
  • Loading branch information
colomon committed Dec 25, 2009
1 parent c9b8720 commit 2cab482
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/core/Array.pm
@@ -1,4 +1,14 @@
augment class Array {
method perl() {
if self.elems() == 0 { return Nil.WHAT };
# '[' ~ self.map({ $_.perl }).join(', ') ~ ']';
my $result = '[';
for 0 ... self.end -> $x {
$result ~= ', ' if $result.chars > 1;
$result ~= self[$x].perl;
}
return $result ~ ']';
}

our method push(*@values) is export {
my @a = @values;
Expand Down
2 changes: 1 addition & 1 deletion src/core/List.pm
Expand Up @@ -5,7 +5,7 @@ augment class List {
my $result = '(';
for self -> $x {
$result ~= ', ' if $result.chars > 1;
$result ~= (~$x.WHAT eq 'Array()' ?? gather { for 0 ... $x.end { take $x.[$_] } } !! $x).perl;
$result ~= $x.perl;
}
return $result ~ ')';
}
Expand Down

0 comments on commit 2cab482

Please sign in to comment.