Sha256: 60dfae428dfa9e305b899225f70cf89ea249122537c99153976ac70a0b49da09
Contents?: true
Size: 582 Bytes
Versions: 122
Compression:
Stored size: 582 Bytes
Contents
module BinarySearch let rec binarySearchAux index value = function | [||] -> None | input -> let middle = input.Length / 2 let middleValue = input.[middle] if value < middleValue then binarySearchAux index value input.[0 .. middle - 1] elif value > middleValue then binarySearchAux (index + middle + 1) value input.[middle + 1 ..] else Some (index + middle) let find input value = if Array.sort input <> input then failwith "The input must be an ordered lists" else binarySearchAux 0 value input
Version data entries
122 entries across 122 versions & 1 rubygems