view chapter7/multiTable.scala @ 0:b316eec6fa7a draft default tip

add sample files
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 08 Jan 2013 16:41:46 +0900
parents
children
line wrap: on
line source

def makeRowSeq(row: Int) =
    for (col <- 1 to 10) yield {
	val prod = (row * col).toString
	val padding = " " * (4 - prod.length)
	padding + prod
    }

def makeRow(row: Int) = makeRowSeq(row).mkString

def multiTable() = {
    val tableSeq = 
	for ( row <- 1 to 10)
		yield makeRow(row)
    tableSeq.mkString("\n")
}

println(multiTable())