tak

Synopsis

(tak x y z)

Parameters

  • x
  • y
  • z

Description

In computer science, the tak function is a recursive function, named after Ikuo Takeuchi.

This function is often used as a benchmark for languages with optimization for recursion, as also with Inlab Scheme with its benchmark functionality.

Side Effects

Return Value

The result is returned as a number.

Implementation

(define (tak x y z)
  (if (not (< y x))
      z
      (tak (tak (1- x) y z)
           (tak (1- y) z x)
   	      (tak (1- z) x y))))

Example

> (tak 18 12 6)
7
>