I'm new to Haskell, the part of my code I'm concerned with is the
isSumAbundant function. Surely there must be a better way, in an imperative language I might use a for loop and break out of the loop if i got greater than n, but it seems like having to filter the list for every single function call is not optimal.
The problem is Problem 23 from project-euler.net.
projectEuler23 = let a = abundantNums 28124 in sum [x | x <- [1..28124], not $ isSumAbundant x a] isSumAbundant n a = any (\x -> (n - x) `elem` a) (takeWhile (<n) a) abundantNums n = [x | x <- [1..n], (>x) $ sum $ properDivisors x] properDivisors n = let limit = (floor.sqrt.fromIntegral) n in [limit | limit^2 == n] ++ ((1:) $ concat [ [x, div n x] | x <- [2..limit - 1], rem n x == 0])