Created
October 8, 2022 19:39
-
-
Save matthinc/0a66e8903931ba0a8b41a33bec4c82b1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Data.Complex (magnitude, Complex ((:+))) | |
main :: IO () | |
main = putStrLn $ foldl (\a r -> a ++ r ++ "\n") "" (row <$> [-1,-0.9..1]) | |
where row r = concat $ (\c -> mandelbrot (c :+ r )) <$> [-2,-1.95..1] | |
mandelbrot c = if (magnitude $ iterations c) > 2 then " " else "*" | |
iterations c = (iterate (\z -> z^2 + c) (0.0 :+ 0.0)) !! 10 | |
$ runghc mandelbrot.hs | |
* ** | |
*** | |
****** | |
****** * | |
********************* | |
********************* | |
* ********************** * | |
******* ************************ | |
********************************** | |
************************************ | |
*********************************************** | |
************************************ | |
********************************** | |
******* ************************ | |
* ********************** * | |
********************* | |
********************* | |
****** * | |
****** | |
*** | |
* ** | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment