Peano curve: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (New draft task and Perl 6 entry) |
m (→{{header|Perl 6}}: added zkl header) |
||
Line 38: | Line 38: | ||
See: [https://github.com/thundergnat/rc/blob/master/img/peano-perl6.svg Peano curve] (SVG image) |
See: [https://github.com/thundergnat/rc/blob/master/img/peano-perl6.svg Peano curve] (SVG image) |
||
=={{header|zkl}}== |
|||
<lang zkl></lang> |
|||
<lang zkl></lang> |
|||
{{out}} |
|||
<pre> |
|||
</pre> |
Revision as of 18:14, 19 July 2018
Peano curve is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
- Task
Produce a graphical or ASCII-art representation of a Peano curve of at least order 3.
Perl 6
<lang perl6>use SVG;
role Lindenmayer {
has %.rules; method succ { self.comb.map( { %!rules{$^c} // $c } ).join but Lindenmayer(%!rules) }
}
my $peano = 'L' but Lindenmayer( { 'L' => 'LFRFL-F-RFLFR+F+LFRFL', 'R' => 'RFLFR+F+LFRFL-F-RFLFR' } );
$peano++ xx 4; my @points = (10, 10);
for $peano.comb {
state ($x, $y) = @points[0,1]; state $d = 0 + 8i; when 'F' { @points.append: ($x += $d.re).round(1), ($y += $d.im).round(1) } when /< + - >/ { $d *= "{$_}1i" } default { }
}
say SVG.serialize(
svg => [ :660width, :660height, :style<stroke:lime>, :rect[:width<100%>, :height<100%>, :fill<black>], :polyline[ :points(@points.join: ','), :fill<black> ], ],
);</lang>
See: Peano curve (SVG image)
zkl
<lang zkl></lang> <lang zkl></lang>
- Output: