Re: Euphoria Standard Library
- Posted by Mike Nelson <MichaelANelson at WORLDNET.ATT.NET> Jul 24, 2001
- 380 views
-- finds x in s, which is assumed to be sorted -- if x is not found returns the negative of the position where it would be inserted (like EDS) global function find_sorted(object x,sequence s) integer min,max,mid,test min=1 max=length(s) while min<=max do mid=floor((min+max)/2) test=compare(x,s[mid]) if test=0 then return mid end if if test>0 then min=mid+1 else max=mid-1 end if end while return -min end function -- Mike Nelson