Class: Locomotive::RelationalAlgebra::RelLambda
- Inherits:
-
Binary
show all
- Defined in:
- lib/locomotive/relational_algebra/operators/abstraction/lambda.rb
Instance Attribute Summary
Attributes inherited from Operator
#schema
#kind, #left_child, #owner, #right_child, #value
Instance Method Summary
collapse
Methods inherited from Operator
#to_xml, #xml_content, #xml_kind, #xml_schema
Methods included from XML
included, #quote, #to_xml
#method_missing, #respond_to?
#has_left_child?, #has_right_child?, #is_leaf?, #traverse, #traverse_strategy=
Constructor Details
#initialize(op1, op2) ⇒ RelLambda
7
8
9
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 7
def initialize(op1, op2)
super(op1,op2)
end
|
Instance Method Details
#apply(arg) ⇒ Object
performs a beta reduction on the right plan side
40
41
42
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 40
def apply(arg)
right.set(left, arg)
end
|
#bound ⇒ Object
74
75
76
77
78
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 74
def bound
[left.clone] + right.bound
end
|
#clone ⇒ Object
44
45
46
47
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 44
def clone
RelLambda.new(op1.clone,
op2.clone)
end
|
#free ⇒ Object
68
69
70
71
72
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 68
def free
right.free - [left]
end
|
#left_and_right(op1, op2) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 11
def left_and_right(op1,op2)
self.schema = Schema.new( { Iter.new(1) => [RNat.type],
Pos.new(1) => [RNat.type],
Item.new(1) => [RNat.type] } )
super(op1,op2)
end
|
#serialize ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 20
def serialize
xml_id = 0
self.traverse do |op|
op.ann_xml_id = xml_id += 1
end
xml_list = []
self.traverse_strategy = Locomotive::AstHelpers::PostOrderTraverse
self.traverse do |op|
xml_list << op.to_xml
end
parametrized_plan :comment => "not mentioned for execution" do
xml_list.join
end
end
|
#set(var, plan) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/locomotive/relational_algebra/operators/abstraction/lambda.rb', line 49
def set(var,plan)
if var == self.left
right.clone
else
if !right.free.member?(var) or
!plan.free.member?(left)
RelLambda.new(
left.clone,
right.set(var, plan))
else
new_var = Variable.new_variable
RelLambda.new(
new_var,
right.set(left,new_var)).set(var,plan)
end
end
end
|