Tree datastructures: Difference between revisions
m
→{{header|Perl 6}}: Minor stylistic twiddles
m (→{{header|zkl}}: added Perl6 example) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Minor stylistic twiddles) |
||
Line 200:
#`(
If, on the other hand, we want perform more complex transformations
load it into a native data structure
however we like.
)
Line 213:
for $tree.lines -> $line {
$line ~~ /^^ ($($level))* /;
when Same { "'{$line.trim}', " }
when Less { "{']' x $last - $this}, '{$line.trim}', " }
}
}
$last = $this;
}
}
$forest ~=
use MONKEY-SEE-NO-EVAL;
$forest.=EVAL;
Line 236 ⟶ 240:
use YAML;
say "\nYAML:\n", $forest.&dump;
}</lang>▼
▲</lang>
{{out}}
<pre>RosettaCode
Line 285 ⟶ 288:
ok 1 - Round-trip equals original
Native data structure:
$["RosettaCode", ["encourages", ["code", ["diversity", "comparison"]], "discourages", ["golfing", "trolling", "emphasising execution speed"]], "code-golf.io", ["encourages", ["golfing"], "discourages", ["comparison"]]]
|