;;;-*- Mode:LISP; Package:BENCH-TAKL; Source->source-optimizations:T; Base:8 -*-
;;; From the "Dick Gabriel" Benchmark Series.
;;; Enhancements (C) Copyright 1983, Lisp Machine, Inc.

;;;BEGIN
;;;TAKL
(defun listn (n)
    (cond
      ((= 0 n)
	nil)
      (t (cons n (listn (1- n))))))

(defun mas (x y z)
    (cond
      ((not (shorterp y x))
	z)
      (t (mas (mas (cdr x)
		   y z)
	      (mas (cdr y)
		   z x)
	      (mas (cdr z)
		   x y)))))

(defun shorterp (x y)
       (and y (or (null x)
		  (shorterp (cdr x)
			    (cdr y)))))

;benchmark is called

;(mas (listn 18) (listn 12) (listn 6))

;(include "timer.lsp")

(declare (special 18l 12l 6l))

(setq 18l (listn 18.)
      12l (listn 12.)
      6l (listn 6.))

(timer timit
       (mas 18l 12l 6l)) 
;;;END
