Project

General

Profile

Actions

Bug #11422

closed

All common set operations produce incorrect (and surprising) results on a set of sets

Added by peterhil (Peter Hillerström) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:70272]

Description

Set operations on a set of sets produce incorrect results

It seems that almost all common set operations (subtract, superset?, subset?, difference, etc...)
produce (mathematically) incorrect results on a set of sets, in that they just return the set of sets unmodified.

The union, intersection, and exclusion operations produce even weirder results, even when
both parameters are sets of sets – some members of the result are scalar values and some are sets.

2.2.2 :119 > ab = Set.new(['A', 'B'])
 => #<Set: {"A", "B"}>
2.2.2 :120 > c = Set.new(['C'])
 => #<Set: {"C"}>
2.2.2 :121 > abc = Set.new([ab, c])

Substraction fails

2.2.2 :122 > abc - c
 => #<Set: {#<Set: {"A", "B"}>, #<Set: {"C"}>}>

Superset fails

2.2.2 :140 > abc > ab
=> false

See more examples on pastie.org.
Python just throws TypeError: unhashable type: 'set'.

Actions

Also available in: Atom PDF

Like0
Like0Like0