module Exercise_6 where import Data.Ratio {-WETT-} traceFractran :: [Rational] -> Integer -> [Integer] traceFractran fs n = if null xs then [n] else n:traceFractran fs (numerator y) where xs = [fromIntegral n * x | x <-fs, denominator (fromIntegral n * x) == 1]; y = head xs {-MCCOMMENT Hello MC! I wanted to ask, if Haskell has any function, which returns the first element of a list that meets a certain condition. In this case for example, I don't care what other elements in xs are except the first one, so it makes no sense to even look at them. I couldn't find anything in the documentary, so all I can come up with is, evaluating the list and taking the head, which is not optimal. (The analogue in other programming languages would be the "break" statement in for/while loops, and Haskell's list comprehension is very similar to these) -} {-TTEW-}