Skip to content

Commit

Permalink
set svn:eol-style
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shyouhei committed Feb 12, 2007
1 parent 1a4b93c commit fd81221
Show file tree
Hide file tree
Showing 81 changed files with 13,317 additions and 13,317 deletions.
30 changes: 15 additions & 15 deletions benchmark/bm_app_answer.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
def ack(m, n)
if m == 0 then
n + 1
elsif n == 0 then
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end

def the_answer_to_life_the_universe_and_everything
(ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i
end

answer = the_answer_to_life_the_universe_and_everything
def ack(m, n)
if m == 0 then
n + 1
elsif n == 0 then
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end

def the_answer_to_life_the_universe_and_everything
(ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i
end

answer = the_answer_to_life_the_universe_and_everything
20 changes: 10 additions & 10 deletions benchmark/bm_app_factorial.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def fact(n)
if(n > 1)
n * fact(n-1)
else
1
end
end

8.times{
fact(5000)
def fact(n)
if(n > 1)
n * fact(n-1)
else
1
end
end

8.times{
fact(5000)
}
20 changes: 10 additions & 10 deletions benchmark/bm_app_fib.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def fib n
if n < 3
1
else
fib(n-1) + fib(n-2)
end
end

fib(34)
def fib n
if n < 3
1
else
fib(n-1) + fib(n-2)
end
end

fib(34)

46 changes: 23 additions & 23 deletions benchmark/bm_app_mandelbrot.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
require 'complex'

def mandelbrot? z
i = 0
while i<100
i+=1
z = z * z
return false if z.abs > 2
end
true
end

ary = []

(0..100).each{|dx|
(0..100).each{|dy|
x = dx / 50.0
y = dy / 50.0
c = Complex(x, y)
ary << c if mandelbrot?(c)
}
}
require 'complex'

def mandelbrot? z
i = 0
while i<100
i+=1
z = z * z
return false if z.abs > 2
end
true
end

ary = []

(0..100).each{|dx|
(0..100).each{|dy|
x = dx / 50.0
y = dy / 50.0
c = Complex(x, y)
ary << c if mandelbrot?(c)
}
}

Loading

0 comments on commit fd81221

Please sign in to comment.