diff -r 9476086849ad -r 372f9801b76d progs/while.scala --- a/progs/while.scala Sat Jan 07 14:52:26 2017 +0000 +++ b/progs/while.scala Sat Jan 07 14:56:45 2017 +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] =