Module: Rucas::Symbolic

Includes:
Utility
Included in:
Scope
Defined in:
lib/rucas/symbolic.rb,
lib/rucas/rewrite.rb,
lib/rucas/simplify.rb

Overview

Translate Ruby expressions into expression trees for symbolic manipulation.

Defined Under Namespace

Modules: Expr, OpExpr Classes: AddExpr, ArithmeticOpExpr, BinaryOpExpr, CompareOpExpr, ConstExpr, DivExpr, EqExpr, GTEqExpr, GTExpr, LTEqExpr, LTExpr, MulExpr, NegExpr, PosExpr, PowExpr, SubExpr, UnaryOpExpr, VarExpr

Constant Summary collapse

CONST_CLASSES =
[Fixnum, Float, Bignum]
UNARY_OPS =
{
  :+@  => :PosExpr,
  :-@  => :NegExpr,
  :~@  => :NotExpr,
}
BINARY_OPS =

Logic – see comments below class BooleanOpExpr < BinaryOpExpr ; end class AndExpr < BooleanOpExpr ; end class OrExpr < BooleanOpExpr ; end

{
:+  => :AddExpr,
:-  => :SubExpr,
:*  => :MulExpr,
:/  => :DivExpr,
:** => :PowExpr,
:=~ => :EqExpr,   # =, == and === are all taken!
:<  => :LTExpr,
:<= => :LTEqExpr,
:>  => :GTExpr,
:>= => :GTEqExpr}

Instance Method Summary collapse

Instance Method Details

#var(name) ⇒ Object

Define variable in this scope and return it.



11
12
13
14
15
16
17
# File 'lib/rucas/symbolic.rb', line 11

def var name
  var = VarExpr.new(name)
  meta_def var.name do
    var
  end
  var
end