Kodama's home / tips.
PQueue or priority queue for ruby is also needed.
To see statistics, use ruby Histogram class.
require "sized_pqueue" t=SizedPQueue.new(5,lambda{|x,y| y>x}) # top 5-data. Set reversed order. [1,2,7,8,3,5,4,9,10,5,6,8].each{|v| t.push(v)} # scan data p t.to_a.join(",") # print out
$ ruby sample.rb "7,8,8,9,10"
require "sized_pqueue" t=SizedPQueue.new(3,lambda{|x,y| y.size>x.size}) # top 3 lines of size readlines.each{|l| t.push(l)} # scan lines t.each_pop{|l| print l} # print out
$ ruby sample.rb < /usr/local/lib/ruby/1.8/expect.rb result = [buf,*mat.to_a[1..-1]] e_pat = Regexp.new(Regexp.quote(pat)) if IO.select([self],nil,nil,timeout).nil? then
原さん(Shin-ichiro HARA) の ruby-list への投稿を見ると, 始めに自分で試した方法よりもすっきりした解決をしていた. ...ということで, 利用させていただきます.
分布,統計を見るには ruby ヒストグラム クラス を使う.
Kodama's home / tips.