Tak (function)

This function is often used as a benchmark for languages with optimization for recursion.

John McCarthy named this function tak() after Takeuchi.

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.