Tak (function)

1

In computer science, the Tak function is a recursive function, named after. It is defined as follows: This function is often used as a benchmark for languages with optimization for recursion.

tak vs. tarai

The original definition by Takeuchi was as follows: tarai is short for in Japanese. John McCarthy named this function tak after Takeuchi. However, in certain later references, the y somehow got turned into the z. This is a small, but significant difference because the original version benefits significantly from lazy evaluation. Though written in exactly the same manner as others, the Haskell code below runs much faster. One can easily accelerate this function via memoization yet lazy evaluation still wins. The best known way to optimize tarai is to use a mutually recursive helper function as follows. Here is an efficient implementation of tarai in C: Note the additional check for before z (the third argument) is evaluated, avoiding unnecessary recursive evaluation.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original