RosettaCodeData/Task/Binary-search/Maple/binary-search-1.maple
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

15 lines
504 B
Text

BinarySearch := proc( A, value, low, high )
description "recursive binary search";
if high < low then
FAIL
else
local mid := iquo( high + low, 2 );
if A[ mid ] > value then
thisproc( A, value, low, mid - 1 )
elif A[ mid ] < value then
thisproc( A, value, mid + 1, high )
else
mid
end if
end if
end proc: