
Brian L. Troutwine wrote:
phi :: (Floating t) => t phi = (1+sqrt(5))/2
even_fibs :: (Num t) => [t] even_fibs = iterate (\x -> round(x * (phi**3))) 2
*Main> :t iterate iterate :: forall a. (a -> a) -> a -> [a] *Main> :t round round :: forall a b. (RealFrac a, Integral b) => a -> b So the 'x' in your anonymous lambda must be (a->a) and the type 'a' must be an integral. You need to convert this Integral 'x' into something that can be used in the math (x * (phi**3)) which is where you need to insert fromIntegral:
even_fibs :: (Integral t) => [t] even_fibs = iterate (\x -> round(fromIntegral x * (phi**3))) 2
Which of course can be tested against
even_fibs_2 = filter even fibs where fibs = 1 : 1 : zipWith (+) (fibs) (tail fibs)
And the phi version fails at
head $ dropWhile (uncurry (==)) $ zip even_fibs even_fibs_2
Which is (37889062373143904,37889062373143906)