Algorithms on Scala/Java/Haskell