changeset 174 | 90e0b1cc460b |
parent 173 | 2de1f79dedf0 |
child 192 | a112e0e2325c |
--- a/progs/lecture2.scala Mon Mar 12 12:11:50 2018 +0000 +++ b/progs/lecture2.scala Tue May 15 01:14:07 2018 +0100 @@ -452,6 +452,12 @@ // function in which return appears." def sq1(x: Int): Int = x * x +def sumq(ls: List[Int]): Int = + ls.map(x => x * x).sum + + + + def sq2(x: Int): Int = return x * x def sumq(ls: List[Int]): Int = { @@ -467,6 +473,7 @@ sqs.sum } +sumq(List(1, 2, 3, 4))