Skip to content
Snippets Groups Projects
Commit 2e198dcf authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

List.tailOption in lib

parent 759170bb
No related branches found
No related tags found
No related merge requests found
...@@ -266,6 +266,14 @@ sealed abstract class List[T] { ...@@ -266,6 +266,14 @@ sealed abstract class List[T] {
None[T]() None[T]()
}} ensuring { _.isDefined != this.isEmpty } }} 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 { def unique: List[T] = this match {
case Nil() => Nil() case Nil() => Nil()
case Cons(h, t) => case Cons(h, t) =>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment