Created
November 2, 2012 19:51
-
-
Save jackfoxy/4003928 to your computer and use it in GitHub Desktop.
Step one in creating a 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 foldHeapStep1 (h : list<BinomialTree<'a>>) = | |
let rec loop (h : list<BinomialTree<'a>>) cont = | |
match h with | |
| Node(_, a, [])::[] -> cont [a] | |
| Node(_, a, h')::[] -> loop h' (fun acc -> cont (a :: acc)) | |
| Node(_, a, [])::tl -> loop tl (fun acc -> cont (a :: acc)) | |
| Node(_, a, h')::tl -> loop h' (fun lacc -> loop tl (fun racc -> cont (a :: racc @ lacc))) | |
| _ -> failwith "can't get here" | |
loop h (fun x -> x) | |
static member private inOrderStep1 (h : list<BinomialTree<'a>>) = BinomialHeap.foldHeap h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment