Jason Lillywhite wrote: > G = 9.8 > > def velocity(c, m, t, dt, vi) > vel = [] > t += dt > steps = t/dt > > steps.times do > v = vi > vi = v + ( G - c/m*v) * dt > vel << v > end > return vel > end > > Is there a better way to do write this function? You can make it a one-liner using range and map: def velocity(c, m, t, dt, v) [v] + (0...t/dt).map { v += (G - c/m*v) * dt } end This version also works with float values of t and dt, which yours rejects because there is no Float#times. -- Posted via http://www.ruby-forum.com/.