Skip to content
Snippets Groups Projects
Commit 67bc0996 authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Strenghten List.find

parent a05c87e5
No related branches found
No related tags found
No related merge requests found
...@@ -410,7 +410,10 @@ sealed abstract class List[T] { ...@@ -410,7 +410,10 @@ sealed abstract class List[T] {
case Nil() => None[T]() case Nil() => None[T]()
case Cons(h, t) if p(h) => Some(h) case Cons(h, t) if p(h) => Some(h)
case Cons(_, t) => t.find(p) case Cons(_, t) => t.find(p)
}} ensuring { res => !res.isDefined || content.contains(res.get) } }} ensuring { res => res match {
case Some(r) => (content contains r) && p(r)
case None() => true
}}
def groupBy[R](f: T => R): Map[R, List[T]] = this match { def groupBy[R](f: T => R): Map[R, List[T]] = this match {
case Nil() => Map.empty[R, List[T]] case Nil() => Map.empty[R, List[T]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment