home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume1
/
8707
/
49
/
ctak.cl
< prev
next >
Wrap
Lisp/Scheme
|
1990-07-13
|
889b
|
38 lines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; File: ctak.cl
; Description: The ctak benchmark
; Author: Richard Gabriel
; Created: 5-Apr-85
; Modified: 10-Apr-85 14:53:02 (Bob Shaw)
; Language: Common Lisp
; Package: User
; Status: Public Domain
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; CTAK -- A version of the TAK function that uses the CATCH/THROW facility.
(defun ctak (x y z)
(catch 'ctak (ctak-aux x y z)))
(defun ctak-aux (x y z)
(declare (fixnum x y z))
(cond ((not (< y x)) ;xy
(throw 'ctak z))
(t (ctak-aux
(catch 'ctak
(ctak-aux (1- x)
y
z))
(catch 'ctak
(ctak-aux (1- y)
z
x))
(catch 'ctak
(ctak-aux (1- z)
x
y))))))
;;; call: (ctak 18 12 6)
(run-benchmark "CTAK" '(ctak 18 12 6))