Module: Rubylog::CompoundTerm
- Defined in:
- lib/rubylog/compound_term.rb
Instance Attribute Summary collapse
-
#rubylog_variables ⇒ Object
readonly
end.
Instance Method Summary collapse
-
#rubylog_match_variables ⇒ Object
returns a copy of the term, with variables with the same name meade same objects.
Instance Attribute Details
#rubylog_variables ⇒ Object
end
47 48 49 |
# File 'lib/rubylog/compound_term.rb', line 47 def rubylog_variables @rubylog_variables end |
Instance Method Details
#rubylog_match_variables ⇒ Object
returns a copy of the term, with variables with the same name meade same objects. Don’t care variables are not matched.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubylog/compound_term.rb', line 5 def rubylog_match_variables vars = []; vars_by_name = {} rubylog_clone do |subterm| case subterm when Rubylog::Variable var = subterm if var.dont_care? # duplicate don't care variables var.dup else # see if a var with that name already exists new_var = vars_by_name[var.name] if new_var # append guards new_var.guards = new_var.guards + var.guards new_var else # create and add new var new_var = var.dup vars << new_var vars_by_name[var.name] = new_var new_var end end when Rubylog::CompoundTerm # save rubylog variables subterm.rubylog_variables=vars subterm else subterm end end end |