Sha256: f2e207947097cc10a244586eb0a9c64c2faf8b64dcdc07c0f7e2e798de324102

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

module SyMath::Operation
  # Repeat method until there are no changes
  def iterate(method)
    ret = deep_clone.send(method)
    if ret == self
      return ret
    else
      return ret.iterate(method)
    end
  end

  # Call method recursively down the arguments of the expression
  # and call self_method on self.
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
symath-0.1.0 lib/symath/operation.rb