Sha256: a87e6e2c6a4c55bf613a099cafc9de8fba64c97d7b3501a1d59ac26349e06694
Contents?: true
Size: 513 Bytes
Versions: 396
Compression:
Stored size: 513 Bytes
Contents
return function(array, target) local function aux(start_index, end_index) if start_index >= end_index then return array[start_index] == target and start_index or -1 end local search_index = math.floor((end_index + start_index) / 2) if array[search_index] == target then return search_index elseif array[search_index] > target then return aux(start_index, search_index - 1) else return aux(search_index + 1, end_index) end end return aux(1, #array) end
Version data entries
396 entries across 396 versions & 1 rubygems