Re: Euphoria Standard Library
- Posted by Tone Skoda <tone.skoda at siol.net> Jul 24, 2001
- 388 views
ok, that function is (a little) better than mine. i didn't know it was already written in EDS, i wouldnt go on writing one bymyself if i knew that. it's also about 1.3x faster. Jeff, you better update it how about "hash tables" which Spellchk.ex uses? if someone would wrap that up to be used as library, that would really be useful. it's maybe 100 times faster than these functions. if i understand it, minimal and maximal values have to be known. (A-Z) ----- Original Message ----- From: Mike Nelson <MichaelANelson at WORLDNET.ATT.NET> To: EUforum <EUforum at topica.com> Sent: Tuesday, July 24, 2001 5:17 PM Subject: Re: Euphoria Standard Library > > > -- 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 > > > >