Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2014 08:03
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 anonymous/a2a784c9f37b1fc6b753 to your computer and use it in GitHub Desktop.
Save anonymous/a2a784c9f37b1fc6b753 to your computer and use it in GitHub Desktop.
# Depth of nesting
N = 100
# Number of floats to allocate
M = 100_000
def chain(next_lambda)
lambda {
puts "."
(1..M).to_a.map { rand }
next_lambda.call
}
end
the_chain = lambda { puts '.' }
N.times do |i|
the_chain = chain(the_chain)
end
the_chain.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment