Module: SyMath::Operation
- Included in:
- Differential, Match, Normalization
- Defined in:
- lib/symath/operation.rb
Defined Under Namespace
Modules: Differential, DistributiveLaw, Exterior, Integration, Match, Normalization
Instance Method Summary collapse
-
#iterate(method, *args) ⇒ Object
Repeat method until there are no changes.
-
#recurse(method, self_method = method) ⇒ Object
Call method recursively down the arguments of the expression and call self_method on self.
Instance Method Details
#iterate(method, *args) ⇒ Object
Repeat method until there are no changes
3 4 5 6 7 8 9 10 |
# File 'lib/symath/operation.rb', line 3 def iterate(method, *args) ret = deep_clone.send(method, *args) if ret == self return ret else return ret.iterate(method, *args) end end |
#recurse(method, self_method = method) ⇒ Object
Call method recursively down the arguments of the expression and call self_method on self.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/symath/operation.rb', line 14 def recurse(method, self_method = method) if is_a?(SyMath::Definition) or is_a?(SyMath::Matrix) if self_method.nil? return self else ret = self.send(self_method) return ret end end # Call method on each argument newargs = args.map { |a| a.send('recurse', method) } ret = self.deep_clone ret.args = newargs if self_method.nil? return ret else return ret.send(self_method) end end |