Cantor set: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
(Added various BASIC dialects (Chipmunk Basic, GW-BASIC, MSX Basic, QBasic, True BASIC and Yabasic)) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 205:
# # # # # # # # # # # # # # # #
</pre>
=={{header|Amazing Hopper}}==
{{Trans|C}}
VERSION 1:
<syntaxhighlight lang="c">
#include <basico.h>
#define WIDTH 81
#define HEIGHT 5
#proto cantor(_X_,_Y_,_Z_)
algoritmo
decimales '0'
dimensionar(HEIGHT,WIDTH) matriz rellena("#",líneas)
_cantor(1, WIDTH, 2)
fijar separador 'NULO', imprimir( líneas, NL)
terminar
subrutinas
cantor(inicio, largo, índice)
seg=0
#( seg:=(int(largo/3))), no es cero?, entonces{
#basic{
líneas[índice:HEIGHT, (inicio+seg):((inicio+seg*2)-1)] = " ")
cantor( inicio, seg, índice+1 ) )
cantor( (inicio+(seg*2)), seg, índice+1 ) )
}
}
retornar
</syntaxhighlight>
{{out}}
<pre>
#################################################################################
########################### ###########################
######### ######### ######### #########
### ### ### ### ### ### ### ###
# # # # # # # # # # # # # # # #
</pre>
{{Trans|Ruby}}
VERSION 2:
<syntaxhighlight lang="c">
#include <basico.h>
#define HEIGHT 5
algoritmo
decimales '0'
cantor="", j=0
iterar
i=0
cadenas 's,v'
iterar grupo ( ++i, #(i< (3^j)),\
#( v = occurs("1", dectobase(i,3)) ? " " : "#"; )\
#( s = s $ replicate(v, 3^(HEIGHT-j-1) )) )
#(cantor = cantor $ s $ NL)
mientras ' #(j<=HEIGHT); ++j '
imprimir(cantor)
terminar
</syntaxhighlight>
{{out}}
<pre>
#################################################################################
########################### ###########################
######### ######### ######### #########
### ### ### ### ### ### ### ###
# # # # # # # # # # # # # # # #
</pre>
=={{header|AppleScript}}==
Line 1,016 ⟶ 1,092:
{{out}}
Same result of Java
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=S87PyS9SMDU15Sooyk9WSE7MKwHyKxQqFYqrFPQU9LgUFBQy00AcOwUDPUMQFwiKq4wVbEGC+grGUKHc/LJUsD5dkCxUsCg1uQSkDCGCZAFYITYpbQUjBS2wJJoiPS49LqgqAwULAwVDAwMuAA== Run it]
<syntaxhighlight>
color 555
proc cantor x y sz . .
if sz > 0.1
sz3 = sz / 3
move x y - sz3
rect sz sz3
cantor x y - sz3 sz3
cantor x + 2 * sz3 y - sz3 sz3
.
.
cantor 0 80 100
</syntaxhighlight>
=={{header|Elixir}}==
Line 4,262 ⟶ 4,356:
=={{header|Wren}}==
{{trans|Kotlin}}
<syntaxhighlight lang="
var height = 5
|