From: Devin Mullins Date: 2006-12-03T02:02:50+09:00 Subject: Re: [OT] calculations on lists of numbers ara.t.howard@noaa.gov wrote: > harp:~> cat a.rb Man, how do you keep all your a.rb's straight? > #! /dmsp/reference/bin/ruby > > require 'narray' > require 'yaml' Am I blind, or do you require 'yaml' and never use it? > list = ARGF.readlines.map{|line| line.strip.split(%r/\s+/).map{|f| > Float f}}.flatten Doesn't this load the whole list of numbers into memory? (i.e. how does it fare on "a billion values"? > na = NArray.to_na list > > puts '---' > %w( min max mean median stddev ).each{|stat| puts "#{ stat }: #{ > na.send stat}"} Devin