module Exercise_6 where import Data.Ratio import Data.List {-WETT-} traceFractran :: [Rational] -> Integer -> [Integer] traceFractran fs n = n : case find (\f -> n `mod` denominator f == 0) fs of Just f -> traceFractran fs $ floor $ fromIntegral n * f Nothing -> [] {-TTEW-} {-traceFractran2 :: [Rational] -> Integer -> [Integer] traceFractran2 fs n = scanl (\n -> concat [ traceFractran2 fs $ floor $ fromIntegral n * f | f <- fs, n `mod` denominator f == 0]) n traceFractran :: [Rational] -> Integer -> [Integer] traceFractran fs n = n : concat [ traceFractran fs $ floor $ fromIntegral n * f | f <- fs, n `mod` denominator f == 0] -} --traceFractranSimple :: [Rational] -> Integer -> [Integer] --traceFractranSimple fs n = n : case find (\f -> n `mod` denominator f == 0) fs of -- Just f -> traceFractranSimple fs $ floor $ fromIntegral n * f -- Nothing -> [] {-traceFractran :: [Rational] -> Integer -> [Integer] traceFractran fs n = n : head (map (\a -> traceFractran fs (div (n * numerator a) (denominator a))) (filter (\a -> mod n (denominator a) == 0) fs)) -}