Time to get this thread back to the active ones
![Smiley :)](/Smileys/phpbb/smiley.gif)
I've tried myself in finding an algorythm to draw the Sierpinski triangle. In a modern BASIC it's not really a problem, because the parameter variables are stored automatically and restored at procedures/functions end. Because it was a nice skill exercise, I ported it to IS-FORTH. Takes me hours of lifetime
![ds_icon_cheesygrin :ds_icon_cheesygrin:](/Smileys/phpbb/ds_icon_cheesygrin.gif)
But to the history, found this
original tweet at Twitter on an ORIC. So, let the work begin.
And here is my IS-Forth result - first time I ever used the word RECURSE. And to see how fast the ARM processor is...
on an Acorn 3020.
Maybe the program can be more compact, my FORTH skills are really at beginners level. And it wasn't so easy for me to deal with four stack values at the same time. But I want to avoid variables, there is no "stackable" variant of them
I want to share it with you, so here is the listing for a first view:
( Drawing Sierpinsky triangle )
: TRIANGLE ( X Y L S -- )
2SWAP 2DUP MOVE ( STARTPOINT )
2SWAP SWAP DUP
0 > IF
SWAP 2SWAP 2DUP
4 PICK + DRAW
2DUP SWAP 4 PICK + SWAP DRAW
2DUP DRAW 2SWAP
2 / SWAP 1 - SWAP
( SHOULD BE X Y L-1 S/2 )
3 PICK 3 PICK 3 PICK 3 PICK
RECURSE
3 PICK 1 PICK + 3 PICK 3 PICK 3 PICK
RECURSE
3 PICK 3 PICK 2 PICK + 3 PICK 3 PICK
RECURSE
2SWAP SWAP
THEN
2DROP 2DROP ;
As attachment it is added as a FORTH editor file, which you can put into file system in EP128emu (Set working directory). And then use
BUFFERS ON " triangle.4th" NAME
LOAD-BUFFERS 1 LOAD
-- Switch to HIRES graphic mode
4 HIRES
-- to run it after loading
0 0 6 700 TRIANGLE