Skip to content

Instantly share code, notes, and snippets.

@matthinc
Created October 8, 2022 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthinc/0a66e8903931ba0a8b41a33bec4c82b1 to your computer and use it in GitHub Desktop.
Save matthinc/0a66e8903931ba0a8b41a33bec4c82b1 to your computer and use it in GitHub Desktop.
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