Class: Rucas::Symbolic::UnaryOpExpr
- Inherits:
-
Struct
- Object
- Struct
- Rucas::Symbolic::UnaryOpExpr
- Includes:
- OpExpr
- Defined in:
- lib/rucas/symbolic.rb,
lib/rucas/rewrite.rb,
lib/rucas/symbolic.rb
Overview
Unary operations.
Constant Summary
Constants included from OpExpr
Instance Attribute Summary collapse
-
#op ⇒ Object
Returns the value of attribute op.
-
#rhs ⇒ Object
Returns the value of attribute rhs.
Instance Method Summary collapse
Methods included from OpExpr
#constant?, #precedence, #rewrite, #with
Methods included from Expr
make, #precedence, #rewrite, #simplify
Instance Attribute Details
#op ⇒ Object
Returns the value of attribute op
102 103 104 |
# File 'lib/rucas/symbolic.rb', line 102 def op @op end |
#rhs ⇒ Object
Returns the value of attribute rhs
102 103 104 |
# File 'lib/rucas/symbolic.rb', line 102 def rhs @rhs end |
Instance Method Details
#children ⇒ Object
106 |
# File 'lib/rucas/symbolic.rb', line 106 def children; [rhs] end |
#match(expr, bindings = {}) ⇒ Object
114 115 116 117 118 |
# File 'lib/rucas/rewrite.rb', line 114 def match expr, bindings = {} return nil unless expr.is_a?(UnaryOpExpr) return nil unless self.op == expr.op rhs.match(expr.rhs, bindings) end |
#to_s_paren ⇒ Object
108 109 110 |
# File 'lib/rucas/symbolic.rb', line 108 def to_s_paren "#{self.op}(#{self.rhs.to_s_paren})" end |
#value ⇒ Object
120 121 122 123 |
# File 'lib/rucas/rewrite.rb', line 120 def value v = rhs.value eval "(#{v}).#{self.op}" if v end |