Iterations in scala