;;; .EnTete "Le-Lisp (c) version 15.2" " " "The Le-Lisp Benchmarks (3)"
;;; .EnPied "stak.ll" "%" " "
;;; .SuperTitre "The Le-Lisp Benchmarks (3)"
;;;
;;; .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: stak.ll,v 1.1 88/10/29 22:10:48 chaillou Exp $"


;;; (3) STAK -- Version of TAK that uses special binding to pass arguments.


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

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

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


(defvar stak-x ())
(defvar stak-y ())
(defvar stak-z ())

(defun stak (stak-x stak-y stak-z)
       (stak-aux))

(defun stak-aux ()
       (if (not (lt stak-y stak-x))
           stak-z
           (let ((stak-x (let ((stak-x (sub1 stak-x)) 
                               (stak-y stak-y)
                               (stak-z stak-z))
                              (stak-aux)))
                 (stak-y (let ((stak-x (sub1 stak-y))
                               (stak-y stak-z)
                               (stak-z stak-x))
                              (stak-aux)))
                 (stak-z (let ((stak-x (sub1 stak-z))
                               (stak-y stak-x)
                               (stak-z stak-y))
                              (stak-aux))))
                (stak-aux))))