Created
November 2, 2012 22:04
-
-
Save jackfoxy/4004621 to your computer and use it in GitHub Desktop.
fold over a BinomialHeap
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
static member private foldHeap nodeF leafV (h : list<BinomialTree<'a>>) = | |
let rec loop (h : list<BinomialTree<'a>>) cont = | |
match h with | |
| Node(_, a, h')::tl -> loop h' (fun lacc -> | |
loop tl (fun racc -> | |
cont (nodeF a lacc racc))) | |
| _ -> cont leafV | |
loop h (fun x -> x) | |
static member private inOrder (h : list<BinomialTree<'a>>) = (BinomialHeap.foldHeap (fun x l r acc -> l (x :: (r acc))) (fun acc -> acc) h) [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment