changeset 470 | 8df654e9eb4e |
parent 93 | 4794759139ea |
child 472 | 372f9801b76d |
--- a/progs/while.scala Mon Nov 14 15:50:42 2016 +0000 +++ b/progs/while.scala Fri Dec 16 11:13:41 2016 +0000 @@ -87,6 +87,19 @@ } } +def len(xs: List[(Int, Int)]): Int = xs match { + case Nil => 0 + case (1, x)::xs => len(xs) + 1 + case (_, x)::xs => len(xs) +} + +def fst(p: (Int, Int)): Int = p match { + case Nil => 0 + case (1, x)::xs => len(xs) + 1 + case (_, x)::xs => len(xs) +} + + // arithmetic expressions lazy val AExp: Parser[List[Token], AExp] =