blob: 36e4256ef05eaca2073c85a6e16f4dc3aba658ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/usr/bin/env ruby
require 'optimist'
require 'zipf'
opts = Optimist::options do
banner "sample --index <n> [--shuffle] [--file <line separated data>]"
opt :file, "Input file.", :type => :string, :default => '-'
opt :index, "Index file.", :type => :string, :required => true
end
input = ReadFile.readlines_strip opts[:file]
index = ReadFile.readlines_strip(opts[:index]).map{ |i| i.to_i }
index.each { |i|
puts input[i]
}
|