Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Mandelbrot-set/Clojure/mandelbrot-set.clj
Normal file
24
Task/Mandelbrot-set/Clojure/mandelbrot-set.clj
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(defn complex-add
|
||||
[[a0 b0] [a1 b1]]
|
||||
[(+ a0 a1) (+ b0 b1)])
|
||||
|
||||
(defn complex-square
|
||||
[[a b]]
|
||||
[(- (* a a) (* b b)) (* 2 a b)])
|
||||
|
||||
(defn complex-abs
|
||||
[[a b]]
|
||||
(Math/sqrt (+ (* a a) (* b b))))
|
||||
|
||||
(defn f
|
||||
[z c]
|
||||
(complex-add z (complex-square c)))
|
||||
|
||||
(defn mandelbrot?
|
||||
[z]
|
||||
(> 2 (complex-abs (nth (iterate (partial f z) [0 0]) 20))))
|
||||
|
||||
(doseq [y (range 1 -1 -0.05)]
|
||||
(doseq [x (range -2 0.5 0.0315)]
|
||||
(print (if (mandelbrot? [(double x) (double y)]) "*" " ")))
|
||||
(println ""))
|
||||
Loading…
Add table
Add a link
Reference in a new issue