Sierpinski carpet: Difference between revisions

Content added Content deleted
(Dialects of BASIC moved to the BASIC section.)
Line 1,263: Line 1,263:
End If
End If
End Sub</syntaxhighlight>
End Sub</syntaxhighlight>

==={{header|Quite BASIC}}===
{{trans|BBC BASIC}}
In Quite BASIC, the point on the lower left on the canvas is 0, 0.
<syntaxhighlight lang="basic" >
10 REM Sierpinski carpet
20 CLS
30 LET R = 3
40 LET S = 1
50 FOR P = 1 TO R
60 LET S = R * S
70 NEXT P
80 REM Now S (size) is 3 to the power of R (order)
90 FOR I = 0 TO S - 1
100 FOR J = 0 TO S - 1
110 LET X = J
120 LET Y = I
130 GOSUB 300
140 IF C = 1 THEN PLOT J, I, "white"
150 NEXT J
160 NEXT I
170 END

300 REM Subroutine -- Is (X,Y) in the carpet?
310 REM Returns C = 0 (no) or C = 1 (yes).
320 LET C = 0
330 IF X % 3 = 1 AND Y % 3 = 1 THEN RETURN
340 LET X = FLOOR(X / 3)
350 LET Y = FLOOR(Y / 3)
360 IF X > 0 OR Y > 0 THEN GOTO 330
370 LET C = 1
380 RETURN
</syntaxhighlight>


==={{header|Sinclair ZX81 BASIC}}===
==={{header|Sinclair ZX81 BASIC}}===