% r is sorted. Store in h a value to truthify
%   r[1..h] <= x < r[h+1..nocols]
function h= bsearch(r, x)
nocols= length(r);
h= 0;  k= nocols + 1;
% inv: r[1..h] <= x < r[k..nocols]
while ( h+1 < k )
    e=  floor( (h+k)/2);
    if r(e) <= x
        h= e;
    else
        k= e;
    end
end