Class: Keisan::Function
- Inherits:
-
Object
show all
- Defined in:
- lib/keisan/function.rb
Direct Known Subclasses
Keisan::Functions::Diff, Keisan::Functions::EnumerableFunction, Keisan::Functions::ExpressionFunction, Keisan::Functions::If, Keisan::Functions::Let, Keisan::Functions::LoopControlFlowFuntion, Keisan::Functions::ProcFunction, Keisan::Functions::Puts, Keisan::Functions::Range, Keisan::Functions::Replace, Keisan::Functions::ToH, Keisan::Functions::While
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, arity = 1) ⇒ Function
Returns a new instance of Function.
5
6
7
8
|
# File 'lib/keisan/function.rb', line 5
def initialize(name, arity = 1)
@name = name
@arity = arity
end
|
Instance Attribute Details
#arity ⇒ Object
Returns the value of attribute arity.
3
4
5
|
# File 'lib/keisan/function.rb', line 3
def arity
@arity
end
|
#name ⇒ Object
Returns the value of attribute name.
3
4
5
|
# File 'lib/keisan/function.rb', line 3
def name
@name
end
|
Instance Method Details
#differentiate(ast_function, variable, context = nil) ⇒ Object
22
23
24
|
# File 'lib/keisan/function.rb', line 22
def differentiate(ast_function, variable, context = nil)
raise Exceptions::NotImplementedError.new
end
|
#evaluate(ast_function, context = nil) ⇒ Object
#simplify(ast_function, context = nil) ⇒ Object
#unbound_variables(children, context) ⇒ Object
26
27
28
29
30
|
# File 'lib/keisan/function.rb', line 26
def unbound_variables(children, context)
children.inject(Set.new) do |vars, child|
vars | child.unbound_variables(context)
end
end
|
#value(ast_function, context = nil) ⇒ Object