Class: Axiom::Algebra::Difference

Inherits:
Relation
  • Object
show all
Includes:
Relation::Operation::Set
Defined in:
lib/axiom/algebra/difference.rb

Overview

The difference between relations

Defined Under Namespace

Modules: Methods

Instance Attribute Summary

Attributes included from Operation::Binary

#left, #right

Attributes inherited from Relation

#header

Instance Method Summary collapse

Methods included from Relation::Operation::Set

#initialize

Methods included from Relation::Operation::Binary

#initialize

Methods included from Operation::Binary

#initialize

Methods inherited from Relation

#==, #[], #directions, #empty?, #include?, #initialize, #materialize, #materialized?, new, #replace

Methods included from Visitable

#accept

Instance Method Details

#delete(other) ⇒ Difference

Delete a relation from the Difference

Remove the relation from the left operand, and add it to the right operand so that it is removed by the difference operation.

Examples:

new_relation = difference.delete(other)

Parameters:

Returns:



60
61
62
# File 'lib/axiom/algebra/difference.rb', line 60

def delete(other)
  left.delete(coerce(other).difference(right)).difference(right)
end

#each {|tuple| ... } ⇒ self

Iterate over each tuple in the set

Examples:

difference = Difference.new(left, right)
difference.each { |tuple| ... }

Yields:

  • (tuple)

Yield Parameters:

  • tuple (Tuple)

    each tuple in the set

Returns:

  • (self)


24
25
26
27
28
# File 'lib/axiom/algebra/difference.rb', line 24

def each
  return to_enum unless block_given?
  left.each { |tuple| yield tuple unless right.include?(tuple) }
  self
end

#insert(other) ⇒ Difference

Insert a relation into the Difference

Add the relation to the left operand, and remove from the right operand so that it not removed by the difference operation.

Examples:

new_relation = difference.insert(other)

Parameters:

Returns:



43
44
45
# File 'lib/axiom/algebra/difference.rb', line 43

def insert(other)
  left.insert(coerce(other).difference(right)).difference(right)
end