I have this code:
trimorficos :: [Integer]
trimorficos = filter (trim) [0..]
trim :: Integer -> Bool
trim x = (show x) `isSuffixOf` (show (x^3))
where a = show x
b = show (x^3)
densityTrimorficos :: Integer -> Double
densityTrimorficos n = fromInteger (n - (genericLength (filter (<=10) trimorficos))) / fromInteger n
Why the last function densityTrimorficos doesn't work?
densityTrimorficos 10doesn't do anything. But if you compile, it doesn't recognize a errorfilterbe replaced withtakeWhile, sincetrimorficosonly increases.