I have one problem with pattern matching. When I give input to **(x:y:ys)** the list containing 3 elements, hugs complain that there is: **pattern match failure**.
I guess that the problem is here

```
takeNearestOnes agent (y:ys) (x:nearestOnes)

```

because it fails to match three elements with list containing two elements

This is full code:

```
takeNearestOnes agent (x:y:ys) nearestOnes
            | first == second =  takeNearestOnes agent (y:ys) (x:nearestOnes)
            | otherwise = (x:nearestOnes)
        where first=(manhattanDistance x (agentCoord agent))
              second=(manhattanDistance y (agentCoord agent)

```

How can I overcome this? Thanks in advance