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
13 14 15 |
# File 'lib/arithmetic.rb', line 13 def ∏(values) values.inject(:*) end |
#∏x(expression, variable, values) ⇒ Object
17 18 19 |
# File 'lib/arithmetic.rb', line 17 def ∏x(expression, variable, values) ∏ (values.map {|value| eval(expression.gsub(variable, value.to_s))}) end |
#∑(values) ⇒ Object
5 6 7 |
# File 'lib/arithmetic.rb', line 5 def ∑(values) values.inject(&:+) end |
#∑x(expression, variable, values) ⇒ Object
21 22 23 |
# File 'lib/arithmetic.rb', line 21 def ∑x(expression, variable, values) ∑ (values.map {|value| eval(expression.gsub(variable, value.to_s))}) end |