Sha256: a08e1d7aacc3c42ea73fdd3796363a4ed4d5254aee7bc31ee5182dfe8659bfed
Contents?: true
Size: 590 Bytes
Versions: 274
Compression:
Stored size: 590 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 binarySearch input value = if Array.sort input <> input then failwith "The input must be an ordered lists" else binarySearchAux 0 value input
Version data entries
274 entries across 274 versions & 1 rubygems