1
2(defun tarai(x y z)
3  (the <fixnum> x)(the <fixnum> y)(the <fixnum> z)
4  (if (<= x y)
5      y
6      (tarai (tarai (- x 1) y z)
7             (tarai (- y 1) z x)
8             (tarai (- z 1) x y))))
9
10(defun fib (n)
11  (the <fixnum> n)
12  (cond ((= n 1) 1)
13        ((= n 2) 1)
14        (t (+ (fib (- n 1)) (fib (- n 2))))))
15
16(defun fib* (n)
17  (cond ((= n 1.0) 1.0)
18        ((= n 2.0) 1.0)
19        (t (+ (fib* (- n 1.0)) (fib* (- n 2.0))))))
20
21(defun ack (m n)
22  (the <fixnum> m)(the <fixnum> n)
23  (cond ((= m 0)(+ n 1))
24        ((= n 0)(ack (- m 1) 1))
25        (t (ack (- m 1) (ack m (- n 1))))))
26
27
28(defgeneric gfib (n)
29   (:method ((n <integer>))
30      (cond ((= n 1) 1)
31            ((= n 2) 1)
32            (t (+ (gfib (- n 1)) (gfib (- n 2)))))))
33
34(defun tak (x y z)
35   (if (>= y x)
36       z
37       (tak (tak (- x 1) y z)
38            (tak (- y 1) z x)
39            (tak (- z 1) x y))))
40
41(defun listn (n)
42   (if (not (= 0 n))
43       (cons n (listn (- n 1)))))
44
45(defconstant ll-18 (listn 18))
46(defconstant ll-12 (listn 12))
47(defconstant ll-6  (listn 6))
48(defconstant ll-32 (listn 32))
49(defconstant ll-16 (listn 16))
50(defconstant ll-8 (listn 8))
51
52(defmacro shorterp (x y)
53   `(< (length ,x) (length ,y)))
54
55(defun takl (x y z)
56   (if (not (shorterp y x))
57       z
58       (takl (takl (cdr x) y z)
59             (takl (cdr y) z x)
60             (takl (cdr z) x y))))
61
62;;call: (takl ll-32 ll-16 ll-8)
63
64(defun ctak (x y z)
65   (catch 'ctak-aux (ctak-aux x y z)))
66
67(defun ctak-aux (x y z)
68   (if (>= y x)
69       (throw 'ctak-aux z)
70       (ctak-aux (catch 'ctak-aux (ctak-aux (- x 1) y z))
71                 (catch 'ctak-aux (ctak-aux (- y 1) z x))
72                 (catch 'ctak-aux (ctak-aux (- z 1) x y)))))
73