Skip to content

Instantly share code, notes, and snippets.

@BenGoldberg1
Created October 7, 2016 03:29
Show Gist options
  • Save BenGoldberg1/a2e8e52bf30639f596711dd6c3c7da11 to your computer and use it in GitHub Desktop.
Save BenGoldberg1/a2e8e52bf30639f596711dd6c3c7da11 to your computer and use it in GitHub Desktop.
proto A(Int \π‘š, Int \𝑛) { (state @)[π‘š][𝑛] //= {*} }
multi A(0, Int \𝑛) { 𝑛 + 1 }
multi A(1, Int \𝑛) { 𝑛 + 2 }
multi A(2, Int \𝑛) { 3 + 2 * 𝑛 }
multi A(3, Int \𝑛) { 5 + 8 * (2 ** 𝑛 - 1) }
multi A(Int \π‘š, 0 ) { A(π‘š - 1, 1) }
multi A(Int \π‘š, Int \𝑛) { A(π‘š - 1, A(π‘š, 𝑛 - 1)) }
say A(4,1);
say .chars, " digits starting with ", .substr(0,50), "..." given A(4,2);
say "Took {now - INIT {now}} seconds."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment