diff --git a/library/collection/List.scala b/library/collection/List.scala index 0fc2d4f84edabf539e6a15476c11388319325126..e75b588c74be5ee9ba3cdfeb22ba857da1b155a7 100644 --- a/library/collection/List.scala +++ b/library/collection/List.scala @@ -266,6 +266,14 @@ sealed abstract class List[T] { None[T]() }} ensuring { _.isDefined != this.isEmpty } + def tailOption: Option[List[T]] = { this match { + case Cons(h, t) => + Some(t) + case Nil() => + None[List[T]]() + }} ensuring { _.isDefined != this.isEmpty } + + def unique: List[T] = this match { case Nil() => Nil() case Cons(h, t) =>