Zen Spider ([info]zenspider) wrote in [info]ruby_lang,

progress on RubyToC

[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!

  • Post a new comment

    Error

  • 1 comments

Anonymous

December 17 2007, 09:23:02 UTC 4 years ago

Hello,
where do you found ./translate.rb?

Best regards
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…