From c9b87200f72e28ace471db4ecd235bb385e55059 Mon Sep 17 00:00:00 2001 From: David Romano Date: Fri, 25 Dec 2009 02:40:57 -0800 Subject: [PATCH] * Allow for .perl to output nested arrays and empty arrays modified: src/core/List.pm --- src/core/List.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/List.pm b/src/core/List.pm index 475be5bc089..b12f225110d 100644 --- a/src/core/List.pm +++ b/src/core/List.pm @@ -1,12 +1,13 @@ augment class List { method perl() { + if self.elems() == 0 { return Nil.WHAT }; # '(' ~ self.map({ $_.perl }).join(', ') ~ ')'; - my $result = "("; + my $result = '('; for self -> $x { - $result ~= ", " if $result.chars > 1; - $result ~= $x.perl; + $result ~= ', ' if $result.chars > 1; + $result ~= (~$x.WHAT eq 'Array()' ?? gather { for 0 ... $x.end { take $x.[$_] } } !! $x).perl; } - return $result ~ ")"; + return $result ~ ')'; } }