Dijkstra on Haskell and Java