September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
31
Task/Mandelbrot-set/Factor/mandelbrot-set.factor
Normal file
31
Task/Mandelbrot-set/Factor/mandelbrot-set.factor
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
! with ("::") or without (":") generalizations:
|
||||
! : [a..b] ( steps a b -- a..b ) 2dup swap - 4 nrot 1 - / <range> ;
|
||||
:: [a..b] ( steps a b -- a..b ) a b b a - steps 1 - / <range> ;
|
||||
|
||||
: >char ( n -- c )
|
||||
dup -1 = [ drop 32 ] [ 26 mod CHAR: a + ] if ;
|
||||
|
||||
! iterates z' = z^2 + c, Factor does complex numbers!
|
||||
: iter ( c z -- z' ) dup * + ;
|
||||
|
||||
: unbound ( c -- ? ) absq 4 > ;
|
||||
|
||||
:: mz ( c max i z -- n )
|
||||
{
|
||||
{ [ i max >= ] [ -1 ] }
|
||||
{ [ z unbound ] [ i ] }
|
||||
[ c max i 1 + c z iter mz ]
|
||||
} cond ;
|
||||
|
||||
: mandelzahl ( c max -- n ) 0 0 mz ;
|
||||
|
||||
:: mandel ( w h max -- )
|
||||
h -1. 1. [a..b] ! range over y
|
||||
[ w -2. 1. [a..b] ! range over x
|
||||
[ dupd swap rect> max mandelzahl >char ] map
|
||||
>string print
|
||||
drop ! old y
|
||||
] each
|
||||
;
|
||||
|
||||
70 25 1000 mandel
|
||||
Loading…
Add table
Add a link
Reference in a new issue