Created
November 2, 2012 20:10
-
-
Save jackfoxy/4004030 to your computer and use it in GitHub Desktop.
Step two in creating a fold over a BinomialHeap
This file contains hidden or 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 foldHeapStep2 c1 c2 c3 (t : list<BinomialTree<'a>>) = | |
let rec loop (h : list<BinomialTree<'a>>) cont = | |
match t with | |
| Node(_, a, [])::[] -> cont (c1 [a]) | |
| Node(_, a, h')::[] -> loop h' (fun acc -> cont (c2 a acc)) | |
| Node(_, a, [])::tl -> loop tl (fun acc -> cont (c2 a acc)) | |
| Node(_, a, h')::tl -> loop h' (fun lacc -> | |
loop tl (fun racc -> | |
cont (c3 a lacc racc))) | |
| _ -> failwith "can't get here" | |
loop h (fun x -> x) | |
static member private inOrderStep2 (h : list<BinomialTree<'a>>) = BinomialHeap.foldHeap (fun acc -> acc) (fun a acc -> a::(acc)) (fun x l r -> x :: r @ l) h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment