class Axiom::Algebra::Union

The union between relations

Public Instance Methods

delete(other) click to toggle source

Delete a relation from the Union

@example

new_relation = union.delete(other)

@param [Relation] other

@return [Union]

@api public

# File lib/axiom/algebra/union.rb, line 56
def delete(other)
  left.delete(other).union(right.delete(other))
end
each() { |seen = tuple| ... } click to toggle source

Iterate over each tuple in the set

@example

union = Union.new(left, right)
union.each { |tuple| ... }

@yield [tuple]

@yieldparam [Tuple] tuple

each tuple in the set

@return [self]

@api public

# File lib/axiom/algebra/union.rb, line 24
def each
  return to_enum unless block_given?
  seen = {}
  left.each  { |tuple| yield seen[tuple] = tuple           }
  right.each { |tuple| yield tuple unless seen.key?(tuple) }
  self
end
insert(other) click to toggle source

Insert a relation into the Union

@example

new_relation = union.insert(other)

@param [Relation] other

@return [Union]

@api public

# File lib/axiom/algebra/union.rb, line 42
def insert(other)
  left.insert(other).union(right.insert(other))
end