Edit this page Backlinks This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Lab 06. Datatypes in Scala ====== Consider the following implementation of a simple datatypes to encode natural number: <code scala> trait Nat {} case object Zero extends Nat {} case class Succ(n: Nat) extends Nat {} val three = Succ(Succ(Succ(Zero))) </code> Write a function which converts a ''Nat'' into an ''Int'': <code scala> def toInt(n: Nat): Int = n match { case Zero => ??? case Succ(n) => ??? } </code>