Implementation of some useful algorithms in Scala