Translation of Ng ML Octave code solutions to Scala