Created
November 12, 2013 00:31
-
-
Save mgonto/7423226 to your computer and use it in GitHub Desktop.
Scala Reactive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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