Created
November 13, 2017 18:27
-
-
Save kunigami/673588c7e8d27815082ab2ce9bbd45fb to your computer and use it in GitHub Desktop.
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
let merge (heap1: heap) (heap2: heap) = match (heap1, heap2) with | |
| (Empty, heap2) -> heap2 | |
| (heap1, Empty) -> heap1 | |
| (Heap (element1, primaryHeap1), Heap (element2, primaryHeap2)) -> | |
if ((Element.compare element1 element2) < 0) | |
then Heap(element1, PrimaryHeap.insert heap2 primaryHeap1) | |
else Heap(element2, PrimaryHeap.insert heap1 primaryHeap2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment