```Hello,

Thank you for all your opinions!

2011/7/18 Michael Edgar <adgar / carboni.ca>:
> This is handy, but what if someone wanted the maximum?

Please invert the condition.  For example, if you want the maximum
index holding that the element is less than 7:

ary = [0, 4, 7, 10, 12]
p (0..4).bserach {|i| !(ary[i] < 7) }  #=> 1

Indeed it is not so cool, but similar to Array#sort.  If it is
possible only by inverting, I'm afraid if we need paticular methods
for each use case.

> Or just the first element that matches?

Good question :-)  Interestingly, break can be used.

ary = [0, 4, 7, 10, 12]
p (0..4).bsearch {|i| break i if ary[i] >= 4 }
#=> 1, 2, 3 or 4 (probably 2, but I don't think it might be changed
in future extension)

> an enumerator for all elements for which the block yields true.

I agree that it seems neat, but it is ambiguous to me how it works
concretely.  What do you expect the following code outputs?

ary = [0, 4, 7, 10, 12]
p (0..4).bsearch_matches {|i| ary[i] >= 4 }.to_a #=> ?

And, I guess binary_matches(&blk).min takes O(m) where m is the
number of results because Enumearble#min and #max find the value by
iterating all elements.

--
Yusuke Endoh <mame / tsg.ne.jp>

```