[#30589] [Bug #3391] Use single exclamation mark instead of double exclamation mark for IRB — Diego Viola <redmine@...>

Bug #3391: Use single exclamation mark instead of double exclamation mark for IRB

10 messages 2010/06/04

[#30672] [Bug #3411] Time.local 1916,5,1 #=> 1916-04-30 23:00:00 +0100 — Benoit Daloze <redmine@...>

Bug #3411: Time.local 1916,5,1 #=> 1916-04-30 23:00:00 +0100

12 messages 2010/06/08

[#30699] [Bug #3419] 1.9.2-preview3 possible bug with Rails 3 active_record sqlite_adapter — Joe Sak <redmine@...>

Bug #3419: 1.9.2-preview3 possible bug with Rails 3 active_record sqlite_adapter

9 messages 2010/06/09

[#30734] [Bug #3428] ri outputs ansi escape sequences even when stdout is not a tty — caleb clausen <redmine@...>

Bug #3428: ri outputs ansi escape sequences even when stdout is not a tty

11 messages 2010/06/11

[#30756] [Feature #3436] Spawn the timer thread lazily — Maximilian Gass <redmine@...>

Feature #3436: Spawn the timer thread lazily

15 messages 2010/06/13
[#32686] [Ruby 1.9-Feature#3436] Spawn the timer thread lazily — Mark Somerville <redmine@...> 2010/10/04

Issue #3436 has been updated by Mark Somerville.

[ruby-core:30897] Re: [Feature #3479] Array#binary_find et al

From: Benoit Daloze <eregontp@...>
Date: 2010-06-25 09:31:46 UTC
List: ruby-core #30897
On 25 June 2010 08:01, Roger Pack <redmine@ruby-lang.org> wrote:
> Thoughts?
> -rp

+1 This would be handful, I had myself more than once to write it in Ruby.

On 25 June 2010 08:52, Shyouhei Urabe <redmine@ruby-lang.org> wrote:
> Issue #3479 has been updated by Shyouhei Urabe.
>
> The problem on sort-and-freeze menu is that in Ruby sorting function might differ every time. e.g.
>
> w"1 70 a3".sort_and_freeze! {|i| i.to_i(16) }.binary_find {|i| i.to_s == "70" }
>
> won't work. es the example above is a bit impractical, but illustrates the difficulty on it.

I do not exactly understand your example, but from what I understand,
you want to sort using a specific comparison (like #sort_by) (which
the example code from RP do not care of).

Well, in this case the binary search must be done on the Array with
the elements you gave to #sort_by, so basically, this would do a #map
before and then sort (and freeze) and the argument for the search
would then be 070.

I think only binary_{find,search,index}(obj) should be proposed (without block).
( I do not see how binary_find {block} could work )

> Though for me, I'm fine with not doing this and allowing for mutable arrays, and just specify that the author must sort them first.
I agree.
It should be specified that a #sort on the Array should change
nothing, then you can safely perform binary_search.

> Array#binary_find (or binary_search, whichever the commiter prefers).

I prefer binary_search, if it returns a boolean, or then binary_find
if it behaves like #find(obj).

B.D.

In This Thread

Prev Next