RosettaCodeData/Task/Binary-search/MiniScript/binary-search-1.mini
2023-07-01 13:44:08 -04:00

7 lines
281 B
Text

binarySearch = function(A, value, low, high)
if high < low then return null
mid = floor((low + high) / 2)
if A[mid] > value then return binarySearch(A, value, low, mid-1)
if A[mid] < value then return binarySearch(A, value, mid+1, high)
return mid
end function