Skip to content

Instantly share code, notes, and snippets.

@melborne
Created July 20, 2011 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melborne/1095106 to your computer and use it in GitHub Desktop.
Save melborne/1095106 to your computer and use it in GitHub Desktop.
fib
# fib plugin
Earthquake.init do
fibo = ->m,a=1,b=1 { Enumerator.new { |y| loop{ y << a; a,b = b,a+b } }.take m }
command :fib do |m|
puts "%d".c(rand(6).+31) % fibo[m[1].to_i].pop
end
command :fibs do |m|
fibs = fibo[m[1].to_i].map { |n| n.to_s.c(rand(6)+31) }
print fibs*' ', "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment