scala: ideomatic and optimized versions

Written as executable scripts. Tested with Scala-2.11.2