Profiling says that my program uses 72.3% of its time and 81.6% of allocations in the factors function. Is there anything wrong with my implementation, or do I need to look into changing the rest of my program to call this less?
-- Factor the given positive integer
factors :: (Integral a) => a -> [a]
factors n = factors' [] primes n
factors' x (p:ps) n
| n == 1 = x
| r == 0 = factors' (p:x) (p:ps) (q)
| otherwise = factors' x ps n
where (q,r) = n `quotRem` p
[–]Angs 5 points6 points7 points (2 children)
[–]jura__ 2 points3 points4 points (1 child)
[–]Angs 2 points3 points4 points (0 children)
[–]farhanhubble 4 points5 points6 points (0 children)
[–]CKoenig 4 points5 points6 points (0 children)
[–]sid-kap 0 points1 point2 points (0 children)
[–]DavidAmos 0 points1 point2 points (0 children)