| Zen Spider ( @ 2004-10-25 00:31:00 |
progress on RubyToC
[crossposted]
% cat fact.rb
% ./translate.rb fact.rb > fact.c
% gcc -Iinc fact.c -o fact
fact.c: In function `main':
fact.c:24: warning: return type of `main' is not `int'
% ./fact
% echo $?
120
HOLY SHIT!!!
super-duper-dodeca-woot!
[crossposted]
% cat fact.rb
class F
def factorial(n)
f = 1
n.downto(2) { |x| f *= x }
return f
end
def main # horrid but funny hack
return factorial(5)
end
end% ./translate.rb fact.rb > fact.c
% gcc -Iinc fact.c -o fact
fact.c: In function `main':
fact.c:24: warning: return type of `main' is not `int'
% ./fact
% echo $?
120
HOLY SHIT!!!
super-duper-dodeca-woot!