Basic iteration in Scala