Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.44 KB | None | 0 0
  1. type HeapNode<'a> =
  2.    { priority : int
  3.      value : 'a
  4.       parent : Heap<'a>
  5.      left : Heap<'a>
  6.       right : Heap<'a> }
  7.  
  8. and Heap<'a> =
  9.     | Empty
  10.     | Node of HeapNode<'a>
  11.      
  12. module Heap =
  13.  
  14.    let private getWith f h =
  15.        match h with
  16.        | Empty -> failwith "empty"
  17.        | Node hn -> f hn
  18.  
  19.    let priority h = h |> getWith (fun hn -> hn.priority)
  20.  
  21.    let value h = h |> getWith (fun hn -> hn.value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement