Created
August 21, 2014 22:44
-
-
Save samth/20b20914bc2e2baa2a38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (mandelbrot/old iterations x y n) | |
(let ([ci (- (/ (* 2.0 y) n) 1.0)] | |
[cr (- (/ (* 2.0 x) n) 1.5)]) | |
(let loop ([i 0] [zr 0.0] [zi 0.0]) | |
(if (> i iterations) | |
i | |
(let ([zrq (* zr zr)] | |
[ziq (* zi zi)]) | |
(cond | |
[(> (+ zrq ziq) 4) i] | |
[else (loop (add1 i) | |
(+ (- zrq ziq) cr) | |
(+ (* 2 zr zi) ci))])))))) | |
(define (mandelbrot/new iterations x y n) | |
(let ([ci (- (/ (* 2.0 y) n) 1.0)] | |
[cr (- (/ (* 2.0 x) n) 1.5)]) | |
(let loop ([i 0] [zr 0.0] [zi 0.0]) | |
(if (> i iterations) | |
i | |
(let ([zrq (* zr zr)] | |
[ziq (* zi zi)]) | |
(cond | |
[(> (+ zrq ziq) 4.0) i] | |
[else (loop (add1 i) | |
(+ (- zrq ziq) cr) | |
(+ (* 2.0 zr zi) ci))])))))) | |
(require future-visualizer) | |
(visualize-futures | |
(let ([f (future (lambda () (mandelbrot/new 10000000 62 501 1000)))]) | |
(list (mandelbrot/new 10000000 62 500 1000) | |
(touch f)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment