Class: Array
Instance Method Summary collapse
-
#a_sum(identity = 0, &block) ⇒ Object
TODO! Change name!.
Instance Method Details
#a_sum(identity = 0, &block) ⇒ Object
TODO! Change name!
11 12 13 14 15 16 17 18 19 |
# File 'lib/classifier/extensions/vector.rb', line 11 def a_sum(identity = 0, &block) return identity unless size > 0 if block_given? map(&block).sum else inject { |sum, element| sum + element }.to_f end end |