Skip to content

Instantly share code, notes, and snippets.

@tomasherman
Created July 2, 2012 08:42

Revisions

  1. tomasherman created this gist Jul 2, 2012.
    8 changes: 8 additions & 0 deletions ch3.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    //E 3.3.4
    def init[A](l: List[A]): List[A] = {
    l match {
    case Nil => Nil
    case Cons(x,Nil) => Nil
    case Cons(x,xs) => Cons(x,init(xs))
    }
    }