Cantor set: Difference between revisions

Content added Content deleted
imported>Chinhouse
No edit summary
Line 2,693: Line 2,693:
{{out}}
{{out}}
A graphic of a Cantor set is shown
A graphic of a Cantor set is shown

=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript">
cantorSet = function(start, length, depth)
if depth == 0 then return [[start, start+length - 1]]
newLen = length / 3
leftInterval = cantorSet(start, newLen, depth - 1)
rightInterval = cantorSet(start + 2 * newLen, newLen, depth - 1)
return leftInterval + rightInterval
end function

for depth in range(0, 4)
output =[" "] * 81
segments = cantorSet(1, 81,depth)
for segment in segments
for x in range(segment[0] - 1, segment[1]-1)
output[x] = "#"
end for
end for
print output.join("")
end for
</syntaxhighlight>
{{out}}
<pre>
#################################################################################
########################### ###########################
######### ######### ######### #########
### ### ### ### ### ### ### ###
# # # # # # # # # # # # # # # #
</pre>

=={{header|Modula-2}}==
=={{header|Modula-2}}==
{{trans|Kotlin}}
{{trans|Kotlin}}