Paste: Draw Sierpinski fractals

Author: harsman
Mode: factor
Date: Sat, 13 Dec 2008 15:39:57
Plain Text |
! Copyright (C) 2008 Joakim HÃ¥rsman
! See http://factorcode.org/license.txt for BSD license.
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

Summary:
Author:
Mode:
Body: