Module: Kernel
- Defined in:
- lib/arithmetic.rb
Instance Method Summary collapse
- #∏(values) ⇒ Object
- #∏x(expression, variable, values) ⇒ Object
- #∑(values) ⇒ Object
- #∑x(expression, variable, values) ⇒ Object
- #√(root) ⇒ Object
Instance Method Details
#∏(values) ⇒ Object
12 13 14 |
# File 'lib/arithmetic.rb', line 12 def ∏(values) values.inject(:*) end |
#∏x(expression, variable, values) ⇒ Object
16 17 18 |
# File 'lib/arithmetic.rb', line 16 def ∏x(expression, variable, values) ∏ (values.map {|value| eval(expression.gsub(variable, value.to_s))}) end |
#∑(values) ⇒ Object
4 5 6 |
# File 'lib/arithmetic.rb', line 4 def ∑(values) values.inject(&:+) end |
#∑x(expression, variable, values) ⇒ Object
20 21 22 |
# File 'lib/arithmetic.rb', line 20 def ∑x(expression, variable, values) ∑ (values.map {|value| eval(expression.gsub(variable, value.to_s))}) end |