Permalink
Browse files

make List.tree more useful

  • Loading branch information...
1 parent a177364 commit 5a2c7d279a4eeb3d541c10fa0ebe0e491142950e @moritz moritz committed Feb 5, 2012
Showing with 3 additions and 1 deletion.
  1. +1 −0 src/core/Any.pm
  2. +1 −1 src/core/List.pm
  3. +1 −0 t/spectest.data
View
@@ -16,6 +16,7 @@ my class Any {
method uniq() { self.list.uniq }
method infinite() { Mu }
method flat() { nqp::p6list(nqp::list(self), List, Bool::True) }
+ method tree() { self.list.tree }
method hash() { my %h = self }
method list() { nqp::p6list(nqp::list(self), List, Mu) }
method pick($n = 1) { self.list.pick($n) }
View
@@ -29,7 +29,7 @@ my class List does Positional {
method flattens() { $!flattens }
method tree() {
- MapIter.new(:list(self), :block({ my $ = $_ })).list;
+ MapIter.new(:list(self), :block({.elems == 1 ?? $_ !! [.list] })).list;
}
method Capture() {
View
@@ -47,6 +47,7 @@ S02-types/type.t
S02-types/undefined-types.t
S02-types/whatever.t
S02-lexical-conventions/unicode.t # icu
+S02-lists/tree.t
S02-literals/array-interpolation.t
S02-literals/autoref.t
S02-literals/char-by-name.t # icu

0 comments on commit 5a2c7d2

Please sign in to comment.