Cantor set: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
→‎{{header|Wren}}: Stack corruption bug now fixed.
Line 1,750: Line 1,750:
ReadChar;
ReadChar;
END Cantor.</lang>
END Cantor.</lang>

=={{header|Nim}}==
{{trans|Kotlin}}

<lang Nim>import strutils

const
Width = 81
Height = 5

var lines: array[Height, string]
for line in lines.mitems: line = repeat('+', Width)

proc cantor(start, length, index: Natural) =
let seg = length div 3
if seg == 0: return
for i in index..<Height:
for j in (start + seg)..<(start + seg * 2):
lines[i][j] = ' '
cantor(start, seg, index + 1)
cantor(start + seg * 2, seg, index + 1)

cantor(0, Width, 1)
for line in lines:
echo line</lang>

{{Out}}
<pre>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++ +++++++++++++++++++++++++++
+++++++++ +++++++++ +++++++++ +++++++++
+++ +++ +++ +++ +++ +++ +++ +++
+ + + + + + + + + + + + + + + +</pre>


=={{header|Perl}}==
=={{header|Perl}}==