Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let find key (xs: ('a * 'b) []) =
- let first,_ = xs.[0]
- match key < first with
- | true -> None
- | _ ->
- let length = Array.length xs
- let rec find key startIndex endIndex =
- match startIndex = endIndex with
- | true -> Some <| xs.[startIndex]
- | _ ->
- let half = startIndex + ((endIndex - startIndex) / 2)
- let date,value = xs.[half]
- match compare key date with
- | 0 -> Some (date,value)
- | 1 -> find key half endIndex
- | _ -> find key startIndex half
- find key 0 (length - 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement