Created
February 7, 2011 18:52
-
-
Save ghulette/814943 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
escapes1 :: RealFloat a => Int -> Complex a -> Bool | |
escapes1 i c = any ((>) 2 . magnitude) (take i ps) | |
where ps = iterate p (0 :+ 0) | |
p = \z -> c + z^(2 :: Int) | |
escapes2 :: RealFloat a => Int -> Complex a -> Bool | |
escapes2 i c = escapes2' i c (0 :+ 0) | |
escapes2' :: RealFloat a => Int -> Complex a -> Complex a -> Bool | |
escapes2' 0 _ _ = False | |
escapes2' !i !c !z = | |
if magnitude z' > 2 then True else escapes2' (pred i) c z' | |
where z' = c + z^(2 :: Int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment