Paste: direct translation of clojure code

Author: slava
Mode: factor
Date: Fri, 20 Feb 2009 18:32:12
Plain Text |
USING: io kernel locals math math.functions math.ranges
sequences tools.time ;
IN: stupid-mandel

CONSTANT: max-iter 99888

:: (iter) ( c z i -- i )
    i max-iter <= [
        z absq 4.0 <= [
            c
            z sq c +
            i 1 + >fixnum
            (iter)
        ] [ i ] if
    ] [ 0 ] if ; inline recursive

: iter ( c -- i ) dup 1 (iter) ; inline

:: mand ( n -- )
    -39 39 [a,b) [| y |
        n 1 = [ nl ] when
        -39 39 [a,b) [| x |
            y 40.0 / 0.5 -
            x 40.0 / rect> iter
            n 1 = [ 0 = "*" " " ? write ] [ drop ] if
        ] each
    ] each ; inline

: time-mand ( -- )
    [ 1 mand ] time ;

New Annotation

Summary:
Author:
Mode:
Body: