Skip to content

Instantly share code, notes, and snippets.

@masak
Created November 13, 2009 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/233491 to your computer and use it in GitHub Desktop.
Save masak/233491 to your computer and use it in GitHub Desktop.
$ cat /tmp/test
class M {
has M @.ms is rw;
method s($i=0) {
$i ~ "[{ map { "{$_.s($i + 1)}" }, self.ms }]"
}
}
my $m = M.new;
my $m2 = M.new;
$m2.ms = M.new;
$m.ms = M.new, $m2, M.new;
say $m.s;
$ perl6 /tmp/test
0[1[] 2[3[]] 4[]]
# expected output:
# 0[1[] 1[2[]] 1[]]
# This used to be code doing indentation before I golfed it. The numbers correspond
# to nesting level.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment