I'm trying to create a function that eliminates multiples of a given Integer from a list of Integers, in the form multiples x [y]
, where x is the given Integer, and y is the list.
Here's what I have:
multiples :: Integer -> [Integer] -> [Integer]
multiples a [] = []
multiples a [b] = filter (\l -> l `mod` a /= 0) [b]
multiples
will fail when called, saying "Non-exhaustive patterns in function multiples". So I used ghci -Wall
with my file to see what patterns were missing, and it returns this:
multiples.hs:2:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for `multiples': Patterns not matched: _ (_:_:_)
multiples.hs:2:11: warning: [-Wunused-matches]
Defined but not used: `a'
I get the feeling I'm missing something really simple with line 2, but I'm a bit stuck. What am I doing wrong?