[Haskell-cafe] How to remove all numbers from a list that are divisible by an integer

Miranda Kajtazi mirandakajtazi at gmail.com
Mon Feb 5 13:11:01 EST 2007

Hi all,
I'm trying to create a function which filters out all number from a list
that are divisible by an integer.
Ex. the list [2,3,4,5,6] div 2...should give me the list like: [3,5], other
numbers should be removed divisible by 2.

filter :: (a -> Bool) -> [a] -> [a]
filter p [] = []
filter p (x:xs) = if p 'mod' x
                       then x : filter p xs
                       else filter p xs
I tried this, but it doesn't work!!!!

Thank You,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070205/7b07fb6f/attachment.htm

More information about the Haskell-Cafe mailing list