Advertisement
florin88

Fancy sintassi

Jan 14th, 2015
2,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.22 KB | None | 0 0
  1. Calcola i primi 15 numeri di Fibonacci:
  2. class Fixnum {
  3.   def fib {
  4.     match self {
  5.       case 0 -> 0
  6.       case 1 -> 1
  7.       case _ -> self - 1 fib + (self - 2 fib)
  8.     }
  9.   }
  10. }
  11.  
  12. 15 times: |x| {
  13.   x fib println
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement