Skip to content

Instantly share code, notes, and snippets.

@kunigami
Created November 13, 2017 18:27
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 kunigami/673588c7e8d27815082ab2ce9bbd45fb to your computer and use it in GitHub Desktop.
Save kunigami/673588c7e8d27815082ab2ce9bbd45fb to your computer and use it in GitHub Desktop.
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