map
o inject
estamos programando
con estilo funcional:
# Compute the average and standard deviation of an array of numbers mean = a.inject {|x,y| x+y } / a.size sumOfSquares = a.map{|x| (x-mean)**2 }.inject{|x,y| x+y } standardDeviation = Math.sqrt(sumOfSquares/(a.size-1))