;;; .EnTete "Le-Lisp (c) version 15.2" " " "The Le-Lisp Benchmarks (2)"
;;; .EnPied "tak.ll" "%" " "
;;; .SuperTitre "The Le-Lisp Benchmarks (2)"
;;;
;;; .Centre "*****************************************************************"
;;; .Centre " Ce fichier est en lecture seule hors du projet ALE de l'INRIA.  "
;;; .Centre " Il est maintenu par ILOG SA, 2 Avenue Gallie'ni, 94250 Gentilly "
;;; .Centre " (c) Le-Lisp est une marque de'pose'e de l'INRIA                 "
;;; .Centre "*****************************************************************"
;;;
;;; .Centre "$Header: tak.ll,v 1.1 88/10/29 21:41:04 chaillou Exp $"

;;; (2) TAK -- Variant of the Takeuchi function, function-call-heavy.


(defun check-tak ()
   (check-value '(test-tak 1) 7))

(defun meter-tak ()
   (perform-meter '(tak 18 12 6) 'tak))

(defun test-tak (n)
   (if (eq n 1)
       (tak 18 12 6)
       (repeat n (tak 18 12 6))))


(defun tak (x y z)
   (if (not (lt y x))
       z
       (tak (tak (sub1 x) y z)
	    (tak (sub1 y) z x)
	    (tak (sub1 z) x y))))