3 ms·
Slightly tangential, but here's my own Sierpinski triangle program from a couple of decades ago, which IMO is considerably simpler than what they show: %!
by WCSTombs 2y ago
Slightly tangential, but here's my own Sierpinski triangle program from a couple of decades ago, which IMO is considerably simpler than what they show:
%!
/threshold 4 def
/Sierpinski {
dup threshold ge {
3 {dup 2 div Sierpinski dup 0 rmoveto 120 rotate} repeat
} {
3 {dup 0 rlineto 120 rotate} repeat closepath
} ifelse
pop
} bind def
50 50 moveto 512 Sierpinski fill
showpage
It actually can be simplified a bit more, and the explicit recursion can be removed entirely, since there's already a free operand stack.