chris-taylor/aima-haskell — pull request #4 by batonius (2012-11-09 23:19:05+00:00)
Title: Priority queue fix

Hi Chris.
I used your implementation of priority queue in my implementation of A*, but it didn't work well, so after fruitless debugging of my code I've found a bug in yours :)

The problem with current implementations is that it can't store multiply values with same priority, since Data.Map keeps only one-to-one relationships and new values frequently overwrites old ones.

For example, for
```haskell
take 2 $ unfoldr (Just . pop)
$ foldr push (newPriorityQueue length) [[1, 2], [3], [4]]
```
result is [[3],[1,2]], not [[3],[4]] or [[4],[3]].

So I've made this quick'n'dirty fix to the bug and it works quite well for me - at least my A* works as expected now :)