I read the tutorials on how to write a for loop in scala but it doesn't seem to work.
object Main {
def pascalTriangle(rows:Int):List[Int]= {
var previousRow:List[Int] = Nil
var row:List[Int] = Nil
for(i <- 1 to rows) {
for( j <- 1 to i+1){
if (j == 1 || j == i)
row :+ 1
else
row :+ previousRow(j) + previousRow(j - 1)
}
previousRow = row
println (row)
row = Nil
}
}
def main(args: Array[String]) {
pascalTriangle(6)
}
}
I keep getting a type mismatch error within the for loop's conditions.