From: Michael Edgar Date: 2011-07-18T15:05:35+09:00 Subject: [ruby-core:38157] Re: [Ruby 1.9 - Feature #4766] Range#bsearch On Jul 18, 2011, at 1:30 AM, Yusuke ENDOH wrote: > I agree that it seems neat, but it is ambiguous to me how it works > concretely. What do you expect the following code outputs? I see now my misunderstanding; the "minimum value" heuristic exists not to provide additional utility, but merely to direct tie-breaking in the binary search in a consistent manner. My proposed bsearch_matches would clearly need to know which direction to break ties before it commenced (perhaps a 1/0/-1 argument), which starts to limit its usefulness. While I personally would prefer this as a base implementation for several methods to bsearch with inverted block condition or "break" in the block, I can't honestly say my idea would be worth it for a first implementation. It does still irk me that the general name "bsearch" would have the minimum-tie-breaking built-in, without that being reflected in the name or an argument. The additional behavior may surprise users. Michael Edgar adgar@carboni.ca http://carboni.ca/