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