Skip to content

Instantly share code, notes, and snippets.

@edisonywh
Created November 30, 2018 09:18
Show Gist options
  • Save edisonywh/60c7d4841e91780cafd64d5145e792f1 to your computer and use it in GitHub Desktop.
Save edisonywh/60c7d4841e91780cafd64d5145e792f1 to your computer and use it in GitHub Desktop.
RubyVM::InstructionSequence.compile_option = {
tailcall_optimization: true,
trace_instruction: false
}
require './tail_recursion.rb'
large_array = Array.new(500_000).fill { |i| i + 1 }
traverse(large_array)
# Element: 1
# Element: ...
# Element: ...
#=> Element: 500000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment