/* A binary search of list A for element M */ search: procedure (A, M) returns (fixed binary); declare (A(*), M) fixed binary; declare (l, r, mid) fixed binary; l = lbound(a,1)-1; r = hbound(A,1)+1; do while (l <= r); mid = (l+r)/2; if A(mid) = M then return (mid); if A(mid) < M then L = mid+1; else R = mid-1; end; return (lbound(A,1)-1); end search;