Paste: Draw Sierpinski fractals
Author: | harsman |
Mode: | factor |
Date: | Sat, 13 Dec 2008 15:39:57 |
Plain Text |
USING: kernel sequences math strings io ;
IN: sierpinski
: simple-scan ( seq -- seq ) accumulate swap suffix 1 tail ;
: bitxor-scan ( seq -- seq ) 0 [ bitxor ] simple-scan ;
: pow ( initial quot n -- ) dup 0 <= [ 2drop ]
[ [ dup ] dip 2slip 1 - pow ] if ; recursive
: render-line ( seq -- ) " *" nths >string print ;
: render ( x -- ) dup 1 <repetition> swap
[ dup render-line bitxor-scan ] swap pow drop ;
New Annotation