Post History
Haskell, 66 bytes -7 bytes thanks to Razetime import Data.Complex (\c->(<2).magnitude$(iterate(\z->z*z+c)c)!!16) I use the fact, that if the result is bigger than 2, it will be fore...
Answer
#7: Post edited
Haskell, 73 bytes- ```
- import Data.Complex
(\c->(<2).magnitude$last$take 16$iterate(\z->z*z+c)c)- ```
- I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end.
- `iterate(\z->z*z+c)c` gives us a list of the results, the original `c` is the first, then I take 16 elements from the list, so with the `last` function I get the last element which was iterated 15 times, that is $z_{16}$ (the first 0 times, the nth element n-1 times). Then I get the absolute value, and compare it with 2.
- Testing:
- ```
- import Data.Complex
- f=(\c->(<2).magnitude $ last $ take 16$ iterate (\z -> z*z+c) c)
- map f [(-1.862069) :+ (-0.3448276),0.3448276 :+ 0.3448276,0.2068966 :+ 0.7586207]
- ```
- gives
- ```
- [False,True,False]
- ```
- Or if you like it better to print to the standard output:
- ```
- main = do print $ map f [(-1.8620690) :+ (-0.3448276), 0.3448276 :+ 0.3448276, 0.2068966 :+ 0.7586207]
- main
- ```
- Haskell, 66 bytes
- -7 bytes thanks to Razetime
- ```
- import Data.Complex
- (\c->(<2).magnitude$(iterate(\z->z*z+c)c)!!16)
- ```
- I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end.
- `iterate(\z->z*z+c)c` gives us a list of the results, the original `c` is the first, then I take 16 elements from the list, so with the `last` function I get the last element which was iterated 15 times, that is $z_{16}$ (the first 0 times, the nth element n-1 times). Then I get the absolute value, and compare it with 2.
- Testing:
- ```
- import Data.Complex
- f=(\c->(<2).magnitude $ last $ take 16$ iterate (\z -> z*z+c) c)
- map f [(-1.862069) :+ (-0.3448276),0.3448276 :+ 0.3448276,0.2068966 :+ 0.7586207]
- ```
- gives
- ```
- [False,True,False]
- ```
- Or if you like it better to print to the standard output:
- ```
- main = do print $ map f [(-1.8620690) :+ (-0.3448276), 0.3448276 :+ 0.3448276, 0.2068966 :+ 0.7586207]
- main
- ```
#6: Post edited
Haskell, 53 bytes- ```
- (\c->(<2).magnitude$last$take 16$iterate(\z->z*z+c)c)
- ```
- I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end.
- `iterate(\z->z*z+c)c` gives us a list of the results, the original `c` is the first, then I take 16 elements from the list, so with the `last` function I get the last element which was iterated 15 times, that is $z_{16}$ (the first 0 times, the nth element n-1 times). Then I get the absolute value, and compare it with 2.
- Testing:
- ```
- import Data.Complex
- f=(\c->(<2).magnitude $ last $ take 16$ iterate (\z -> z*z+c) c)
- map f [(-1.862069) :+ (-0.3448276),0.3448276 :+ 0.3448276,0.2068966 :+ 0.7586207]
- ```
- gives
- ```
- [False,True,False]
- ```
- Or if you like it better to print to the standard output:
- ```
- main = do print $ map f [(-1.8620690) :+ (-0.3448276), 0.3448276 :+ 0.3448276, 0.2068966 :+ 0.7586207]
- main
- ```
- Haskell, 73 bytes
- ```
- import Data.Complex
- (\c->(<2).magnitude$last$take 16$iterate(\z->z*z+c)c)
- ```
- I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end.
- `iterate(\z->z*z+c)c` gives us a list of the results, the original `c` is the first, then I take 16 elements from the list, so with the `last` function I get the last element which was iterated 15 times, that is $z_{16}$ (the first 0 times, the nth element n-1 times). Then I get the absolute value, and compare it with 2.
- Testing:
- ```
- import Data.Complex
- f=(\c->(<2).magnitude $ last $ take 16$ iterate (\z -> z*z+c) c)
- map f [(-1.862069) :+ (-0.3448276),0.3448276 :+ 0.3448276,0.2068966 :+ 0.7586207]
- ```
- gives
- ```
- [False,True,False]
- ```
- Or if you like it better to print to the standard output:
- ```
- main = do print $ map f [(-1.8620690) :+ (-0.3448276), 0.3448276 :+ 0.3448276, 0.2068966 :+ 0.7586207]
- main
- ```
#5: Post edited
- Haskell, 53 bytes
- ```
(\c->(<2).magnitude$last$take 17$iterate(\z->z*z+c)c)- ```
- I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end.
`iterate(\z->z*z+c)c` gives us a list of the results, the original `c` is the first, then I take 17 elements from the list, so with the `last` function I get the last element which was iterated 16 times (the first 0 times, the nth element n-1 times). Then I get the absolute value, and compare it with 2.- Testing:
- ```
- import Data.Complex
f=(\c->(<2).magnitude $ last $ take 17$ iterate (\z -> z*z+c) c)- map f [(-1.862069) :+ (-0.3448276),0.3448276 :+ 0.3448276,0.2068966 :+ 0.7586207]
- ```
- gives
- ```
- [False,True,False]
- ```
- Or if you like it better to print to the standard output:
- ```
- main = do print $ map f [(-1.8620690) :+ (-0.3448276), 0.3448276 :+ 0.3448276, 0.2068966 :+ 0.7586207]
- main
- ```
- Haskell, 53 bytes
- ```
- (\c->(<2).magnitude$last$take 16$iterate(\z->z*z+c)c)
- ```
- I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end.
- `iterate(\z->z*z+c)c` gives us a list of the results, the original `c` is the first, then I take 16 elements from the list, so with the `last` function I get the last element which was iterated 15 times, that is $z_{16}$ (the first 0 times, the nth element n-1 times). Then I get the absolute value, and compare it with 2.
- Testing:
- ```
- import Data.Complex
- f=(\c->(<2).magnitude $ last $ take 16$ iterate (\z -> z*z+c) c)
- map f [(-1.862069) :+ (-0.3448276),0.3448276 :+ 0.3448276,0.2068966 :+ 0.7586207]
- ```
- gives
- ```
- [False,True,False]
- ```
- Or if you like it better to print to the standard output:
- ```
- main = do print $ map f [(-1.8620690) :+ (-0.3448276), 0.3448276 :+ 0.3448276, 0.2068966 :+ 0.7586207]
- main
- ```
#4: History hidden
Haskell, 53 bytes ``` (\c->(<2).magnitude$last$take 17$iterate(\z->z*z+c)c) ``` I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end. `iterate(\z->z*z+c)c` gives us a list of the results, the original `c` is the first, then I take 17 elements from the list, so with the `last` function I get the last element which was iterated 16 times (the first 0 times, the nth element n-1 times). Then I get the absolute value, and compare it with 2. Testing: ``` import Data.Complex f=(\c->(<2).magnitude $ last $ take 17$ iterate (\z -> z*z+c) c) map f [(-1.862069) :+ (-0.3448276),0.3448276 :+ 0.3448276,0.2068966 :+ 0.7586207] ``` gives ``` [False,True,False] ``` Or if you like it better to print to the standard output: ``` main = do print $ map f [(-1.8620690) :+ (-0.3448276), 0.3448276 :+ 0.3448276, 0.2068966 :+ 0.7586207] main ```