Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git] / bench / shootout / ary.ruby
blob15024ba5a3c1bfd22f9ce9b4ee1c4b46444bef51
1 #!/usr/bin/ruby
2 # -*- mode: ruby -*-
3 # $Id: ary.ruby,v 1.3 2004-06-20 08:39:45 bfulgham Exp $
4 # http://www.bagley.org/~doug/shootout/
5 # with help from Paul Brannan and Mark Hubbart
7 n = Integer(ARGV.shift || 1)
9 x = Array.new(n)
10 y = Array.new(n, 0)
12 for i in 0 ... n
13 x[i] = i + 1
14 end
16 (0 .. 999).each do
17 (n-1).step(0,-1) do |i|
18 y[i] += x.at(i)
19 end
20 end
22 puts "#{y.first} #{y.last}"