9 lines
361 B
Text
9 lines
361 B
Text
fcn bsearch(list,value){ // list is sorted
|
|
fcn(list,value, low,high){
|
|
if (high < low) return(Void); // not found
|
|
mid:=(low + high) / 2;
|
|
if (list[mid] > value) return(self.fcn(list,value, low, mid-1));
|
|
if (list[mid] < value) return(self.fcn(list,value, mid+1, high));
|
|
return(mid); // found
|
|
}(list,value,0,list.len()-1);
|
|
}
|