Class: Rucas::Symbolic::VarExpr

Inherits:
Struct
  • Object
show all
Includes:
Expr
Defined in:
lib/rucas/symbolic.rb,
lib/rucas/rewrite.rb,
lib/rucas/symbolic.rb

Overview

Variable (literal).

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Expr

#children, make, #precedence, #rewrite, #simplify, #to_s_paren, #value

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



55
56
57
# File 'lib/rucas/symbolic.rb', line 55

def name
  @name
end

Instance Method Details

#constant?Boolean

Returns:

  • (Boolean)


60
# File 'lib/rucas/symbolic.rb', line 60

def constant?; false end

#match(expr, bindings = {}) ⇒ Object



101
102
103
104
105
106
# File 'lib/rucas/rewrite.rb', line 101

def match expr, bindings = {}
  binding = bindings[self]
  return bindings.merge(self => expr) if !binding
  return bindings                     if binding == expr
  return nil
end

#to_sObject



59
# File 'lib/rucas/symbolic.rb', line 59

def to_s; name.to_s end

#with(bindings) ⇒ Object



108
109
110
# File 'lib/rucas/rewrite.rb', line 108

def with bindings
  bindings[self] || self
end