Skip to content

Instantly share code, notes, and snippets.

@bmarcot
Last active December 16, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmarcot/5403134 to your computer and use it in GitHub Desktop.
Save bmarcot/5403134 to your computer and use it in GitHub Desktop.
object List {
// List()
def apply[T]() = new Nil
// List(1)
def apply[T](x1: T): List[T] = new Cons(x1, new Nil)
// List(1, 2)
def apply[T](x1: T, x2: T): List[T] = new Cons(x1, new Cons(x2, new Nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment