;;; .EnTete "Le-Lisp (c) version 15.2" " " "The Le-Lisp Benchmarks (5)"
;;; .EnPied "takl.ll" "%" " "
;;; .SuperTitre "The Le-Lisp Benchmarks (5)"
;;;
;;; .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: takl.ll,v 1.1 88/10/29 22:11:05 chaillou Exp $"
;;; (5) TAKL -- Like TAK, but without any explicit arithmetic.
(defun check-takl ()
(check-value '(test-takl 1) '(7 6 5 4 3 2 1)))
(defun meter-takl ()
(perform-meter '(takl ll-18 ll-12 ll-6) 'takl))
(defun test-takl (n)
(if (eq n 1)
(takl ll-18 ll-12 ll-6)
(repeat n (takl ll-18 ll-12 ll-6))))
(defun listn (n)
(if (not (= 0 n))
(cons n (listn (sub1 n))))))
(defvar ll-18 (listn 18))
(defvar ll-12 (listn 12))
(defvar ll-6 (listn 6))
(defun takl (x y z)
(if (not (shorterp y x))
z
(takl (takl (cdr x) y z)
(takl (cdr y) z x)
(takl (cdr z) x y))))
(defun shorterp (x y)
(when y
(if x
(shorterp (cdr x) (cdr y))
t)))