Recursion is beautiful. As an example, let's consider this perfectly acceptable example of defining the functions even
and odd
in Scala, whose semantics you can guess:
def even(i: Int): Boolean = i match {
case 0 => true
case _ => odd(i - 1)
}
def odd(i: Int): Boolean = i match {