use Collections.*
use Optional.*
fun binarySearch(target: T)
on (Ordered<T>,Indexed<Int,T>):
Optional<Int[min=0,max=this.size]> {
low = 0
high = this.size - 1
while (low <= high){
mid = (low + high) / 2
comparison = this.orderer(this[mid], target)
if (comparison < 0){
low = mid + 1
} elif (comparison > 0){
high = mid -1
} else {
return Some(mid)
}
}
return None
}