[#55853] ruby 1.9.3 p448 breaks ABI — V咜 Ondruch <v.ondruch@...>

Hi,

13 messages 2013/07/08

[#55951] [ruby-trunk - Bug #8625][Open] IO#read(len, buf) shortens buf even if data is not read actually — "no6v (Nobuhiro IMAI)" <nov@...>

10 messages 2013/07/11

[#55976] [ruby-trunk - Feature #8629][Open] Method#parameters should include the default value — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

13 messages 2013/07/12

[#55985] [ruby-trunk - Feature #8631][Open] Add a new method to ERB to allow assigning the local variables from a hash — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

19 messages 2013/07/12

[#56004] [ruby-trunk - Feature #8636][Open] Documentation hosting on ruby-lang.org — "zzak (Zachary Scott)" <e@...>

18 messages 2013/07/15

[#56019] [ruby-trunk - Feature #8639][Open] Add Queue#each — "avdi (Avdi Grimm)" <avdi@...>

15 messages 2013/07/15

[#56027] [CommonRuby - Feature #8640][Open] Add Time#elapsed to return nanoseconds since creation — "tenderlovemaking (Aaron Patterson)" <aaron@...>

24 messages 2013/07/15

[#56041] [CommonRuby - Feature #8643][Open] Add Binding.from_hash — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

26 messages 2013/07/16

[#56087] [ruby-trunk - Feature #8658][Open] Process.clock_gettime — "akr (Akira Tanaka)" <akr@...>

23 messages 2013/07/19

[#56096] [CommonRuby - Feature #8661][Open] Add option to print backstrace in reverse order(stack frames first & error last) — "gary4gar (Gaurish Sharma)" <gary4gar@...>

18 messages 2013/07/20

[#56193] [ruby-trunk - Bug #8693][Open] lambda invoked by yield acts as a proc with respect to return — "rits (First Last)" <redmine@...>

33 messages 2013/07/26

[#56274] [ruby-trunk - Bug #8709][Open] Dir.glob should return sorted file list — "tommorris (Tom Morris)" <tom@...>

19 messages 2013/07/30

[ruby-core:56268] [ruby-trunk - Feature #6588] Set#intersect?

From: "knu (Akinori MUSHA)" <knu@...>
Date: 2013-07-30 10:19:21 UTC
List: ruby-core #56268
Issue #6588 has been updated by knu (Akinori MUSHA).


I followed superset?() and the like, and made the new methods accept only a set for the moment, because I couldn't come up with an idea of how to deal with Range.  For example:

- if Set[2].intersect?(1.5..2.5) should return true
- if Set[2].intersect?(3..(1.0/0)) should immediately return false using some knowledge on Range

----------------------------------------
Feature #6588: Set#intersect?
https://bugs.ruby-lang.org/issues/6588#change-40759

Author: marcandre (Marc-Andre Lafortune)
Status: Closed
Priority: Normal
Assignee: knu (Akinori MUSHA)
Category: lib
Target version: next minor


There is `Set#superset?`, `Set#subset?` with their `proper` variants, but there is no `Set#intersect?` nor `Set#disjoint?`

To check if two sets intersect, one can do

  set.intersection(other).empty?

This cycles through all elements, though. To be efficient, one can instead do the iteration manually:

  other.any? { |x| set.include?(x) }

I think it would be natural to add `Set#intersect?` and its reverse `Set#disjoint?`

  class Set
    def intersect?(enum)
      enum.any? { |x| include?(x) }
    end
  end

Maybe it would be worth it to optimize it if enum is a larger Set by starting it with

      return any? { |x| enum.include?(x) } if enum.is_a?(Set) && enum.size > size



-- 
http://bugs.ruby-lang.org/

In This Thread

Prev Next