Skip to content

Instantly share code, notes, and snippets.

@mgonto
Created November 12, 2013 00:31
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 mgonto/7423226 to your computer and use it in GitHub Desktop.
Save mgonto/7423226 to your computer and use it in GitHub Desktop.
Scala Reactive
def heapList(heap: H): List[A] = {
if (isEmpty(heap)) {
Nil
} else {
findMin(heap) :: heapList(deleteMin(heap))
}
}
property("Added and removed elements") = forAll { (h: H, values: List[A]) =>
val listOfElemsBefore = heapList(h)
val heapWithAll = values.foldLeft(h)((acum, value) => insert(value, acum))
val listOfElems = heapList(heapWithAll)
listOfElems.diff(listOfElemsBefore) == values.sorted(ord)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment