Zen Spider ([info]zenspider) wrote in [info]ruby_lang,
@ 2004-10-25 00:31:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
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)


(Anonymous)
2007-12-17 09:23 am UTC (link)
Hello,
where do you found ./translate.rb?

Best regards

(Reply to this)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…