Cantor set: Difference between revisions
Content deleted Content added
Added various BASIC dialects (Chipmunk Basic, GW-BASIC, MSX Basic, QBasic, True BASIC and Yabasic) |
|||
Line 205: | Line 205: | ||
# # # # # # # # # # # # # # # # |
# # # # # # # # # # # # # # # # |
||
</pre> |
</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{ |
|||
#(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 WIDTH 81 |
|||
#define HEIGHT 5 |
|||
algoritmo |
|||
decimales '0' |
|||
seg_size = 0, lines=5, l=0 |
|||
iterar para (j=0, #(j<=lines), ++j) |
|||
#(seg_size = 3^(lines-j-1)) |
|||
c="", i=0 |
|||
iterar grupo ( ++i, #(i< (3^j)),\ |
|||
#( c = cat( c, occurs("1", dectobase(i,3)) ? " " : "#";))) |
|||
#(l=len(c)), s="" |
|||
para cada caracter(v, c, l) |
|||
#( s = cat(s, replicate( v, seg_size ))) |
|||
siguiente |
|||
imprimir (s, NL) |
|||
siguiente |
|||
terminar |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
################################################################################# |
|||
########################### ########################### |
|||
######### ######### ######### ######### |
|||
### ### ### ### ### ### ### ### |
|||
# # # # # # # # # # # # # # # # |
|||
</pre> |
|||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||