PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/ruby/template/runme.rb

#
Ruby | 25 lines | 13 code | 9 blank | 3 comment | 0 complexity | 4409443e83e160ba328c5032f3f52b1a MD5 | raw file
 1# file: runme.rb
 2
 3require 'example'
 4
 5# Call some templated functions
 6puts Example::maxint(3, 7)
 7puts Example::maxdouble(3.14, 2.18)
 8
 9# Create some class
10
11iv = Example::Vecint.new(100)
12dv = Example::Vecdouble.new(1000)
13
14100.times { |i| iv.setitem(i, 2*i) }
15
161000.times { |i| dv.setitem(i, 1.0/(i+1)) }
17
18sum = 0
19100.times { |i| sum = sum + iv.getitem(i) }
20
21puts sum
22
23sum = 0.0
241000.times { |i| sum = sum + dv.getitem(i) }
25puts sum