module Exercise_6 where import Data.Ratio {-WETT-} traceFractran :: [Rational] -> Integer -> [Integer] traceFractran xs n = let pass = [numerator x * n `div` denominator x|x<-xs, n`mod`denominator x == 0] in [n] ++ if pass /= [] then traceFractran xs (head pass) else [] {-TTEW-} --isPowerOfTwo :: Integer -> Bool --isPowerOfTwo x -- | x == 2 = True -- | x `mod` 2 == 0 = True && isPowerOfTwo (x `div` 2) -- | otherwise = False -- --traceFractran2 :: [Rational] -> Integer -> [Integer] --traceFractran2 xs n = aux xs xs n -- where -- aux [] ys n = [n] -- aux (x:xs) ys n -- | n `mod` (denominator x) == 0 && n > 0 = [n] ++ traceFractran2 ys ((numerator x * n)`div`(denominator x)) -- | otherwise = aux xs ys n -- [numerator x * n `div` denominator x|x<-xs, n`mod`denominator x == 0]] --traceFractran xs n = let pass = [numerator $ x*fromInteger n|x<-xs, denominator (x*fromInteger n) == 1] in if pass /= [] then [n] ++ traceFractran xs (head pass) else [n] --traceFractran xs n = let pass = [numerator x*n|x<-xs, denominator (x*n) == 1] in if pass /= [] then [n] ++ traceFractran xs (head pass) else [n]