encyclopegia.org

Tak (function)

In computer science, the Tak function is a recursive function, named after . It is defined as follows: \tau (x,y,z) = \begin{cases} \tau (\tau (x-1,y,z) ,\tau (y-1,z,x) ,\tau (z-1,x,y) ) & \text{if } y def tak(x: int, y: int, z: int) -> int: if y This function is often used as a benchmark for languages with optimization for recursion.

In computer science, the Tak function is a recursive function, named after . It is defined as follows: \tau (x,y,z) = \begin{cases} \tau (\tau (x-1,y,z) ,\tau (y-1,z,x) ,\tau (z-1,x,y) ) & \text{if } y def tak(x: int, y: int, z: int) -> int: if y 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: def tarai(x: int, y: int, z: int) -> int: if y 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. tarai :: Int -> Int -> Int -> Int tarai x y z | x 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. def laziest_tarai(x: int, y: int, zx: int, zy: int, zz: int) -> int: if not y int: if not y Here is an efficient implementation of tarai() in C: int tarai(int x, int y, int z) { while (x > y) { int oldx = x, oldy = y; x = tarai(x - 1, y, z); y = tarai(y - 1, z, oldx); if (x Note the additional check for ( x ) before z (the third argument) is evaluated, avoiding unnecessary recursive evaluation. ==References== ==External links== TAK Function

References

  1. Tak test stands the test of time · retrieved 2026-11-17 · rev 1301932557
    Cite this reference

    MLA "Tak test stands the test of time." Peter Coffee (1996). 2026-11-17. https://en.wikipedia.org/w/index.php?oldid=1301932557. Accessed 24 November 2026.

    Chicago "Tak test stands the test of time." Peter Coffee (1996). 2026-11-17. https://en.wikipedia.org/w/index.php?oldid=1301932557.

    APA Peter Coffee (1996). (2026). Tak test stands the test of time. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1301932557

  2. Recursive Methods · retrieved 2026-11-17 · rev 1301932557
    Cite this reference

    MLA "Recursive Methods." "Recursive Methods" by Elliotte Rusty Harold Wikipedia revision 1301932557, retrieved 2026-11-18. 2026-11-17. http://buildingblocksjava.com/recursive-methods/. Accessed 24 November 2026.

    Chicago "Recursive Methods." "Recursive Methods" by Elliotte Rusty Harold Wikipedia revision 1301932557, retrieved 2026-11-18. 2026-11-17. http://buildingblocksjava.com/recursive-methods/.

    APA "Recursive Methods" by Elliotte Rusty Harold Wikipedia revision 1301932557, retrieved 2026-11-18. (2026). Recursive Methods. Retrieved November 24, 2026, from http://buildingblocksjava.com/recursive-methods/

  3. An Interesting LISP Function · retrieved 2026-11-17 · rev 1301932557
    Cite this reference

    MLA "An Interesting LISP Function." John McCarthy (December 1979). 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier). Accessed 24 November 2026.

    Chicago "An Interesting LISP Function." John McCarthy (December 1979). 2026-11-17. https://en.wikipedia.org/wiki/Doi_(identifier).

    APA John McCarthy (December 1979). (2026). An Interesting LISP Function. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Doi_(identifier)

  4. Six of the Best Against the Clock · retrieved 2026-11-17 · rev 1301932557
    Cite this reference

    MLA "Six of the Best Against the Clock." Johnson-Davies, David (June 1986). 2026-11-17. https://archive.org/details/AcornUser047-Jun86/page/n180/mode/1up. Accessed 24 November 2026.

    Chicago "Six of the Best Against the Clock." Johnson-Davies, David (June 1986). 2026-11-17. https://archive.org/details/AcornUser047-Jun86/page/n180/mode/1up.

    APA Johnson-Davies, David (June 1986). (2026). Six of the Best Against the Clock. Retrieved November 24, 2026, from https://archive.org/details/AcornUser047-Jun86/page/n180/mode/1up

  5. Testing the Tak · retrieved 2026-11-17 · rev 1301932557
    Cite this reference

    MLA "Testing the Tak." Johnson-Davies, David (November 1986). 2026-11-17. https://archive.org/details/AcornUser052-Nov86/page/n198/mode/1up. Accessed 24 November 2026.

    Chicago "Testing the Tak." Johnson-Davies, David (November 1986). 2026-11-17. https://archive.org/details/AcornUser052-Nov86/page/n198/mode/1up.

    APA Johnson-Davies, David (November 1986). (2026). Testing the Tak. Retrieved November 24, 2026, from https://archive.org/details/AcornUser052-Nov86/page/n198/mode/1up

Cite this article

MLA

"Tak (function)." encyclopegia.org, 2025, https://encyclopegia.org/wiki/tak-function. Accessed 24 November 2026.

Chicago

"Tak (function)." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/tak-function.

APA

encyclopegia.org. (2025). Tak (function). Retrieved November 24, 2026, from https://encyclopegia.org/wiki/tak-function

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Arvid Noe

enwiki · references available

Alfonso Barrantes

enwiki · references available

The Ship (video game)

enwiki · references available

Lou Carpenter

enwiki · references available

Mirzapur Cadet College

enwiki · references available

Freestyle motocross

enwiki · references available

William Shakespeare's collaborations

enwiki · references available

Hipparchia of Maroneia

enwiki · references available

Hinduism in South Africa

enwiki · references available

Tsendiin Nyamdorj

enwiki · references available

Dha (sword)

enwiki · references available

Onna-musha

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1301932557 · 0.5 · snapshot enwiki-001301932557

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.