Quite redundant now, maybe.
prim' :: (Integral a) => [a] -> [a]
prim' []= []
prim' (x:xs) = x : (prim' $ foldl (\acc z -> if (z `mod` x) == 0 then acc else acc ++ [z]) [] xs)
Here is the testing result of it.
> prim' [2..100]
[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
No comments:
Post a Comment