1;;; DIV2 -- Benchmark which divides by 2 using lists of n ()'s.
2;;; This file contains a recursive as well as an iterative test.
3
4(defun create-n (n)
5  (declare (type fixnum n))
6  (do ((n n (the fixnum (1- n)))
7       (a () (push () a)))
8      ((= (the fixnum n) 0) a)
9    (declare (type fixnum n))))
10
11(defparameter **l** (create-n 200))
12
13(defun iterative-div2 (l)
14  (do ((l l (cddr l))
15       (a () (push (car l) a)))
16      ((null l) a)))
17
18(defun recursive-div2 (l)
19  (cond ((null l) ())
20        (t (cons (car l) (recursive-div2 (cddr l))))))
21
22(defun test-div2-iterative (&optional (l **l**))
23  (do ((i 300 (the fixnum (1- i))))
24      ((= (the fixnum i) 0))
25    (declare (type fixnum i))
26    (iterative-div2 l)
27    (iterative-div2 l)
28    (iterative-div2 l)
29    (iterative-div2 l)))
30
31(defun test-div2-recursive (&optional (l **l**))
32  (do ((i 300 (the fixnum (1- i))))
33      ((= (the fixnum i) 0))
34    (declare (type fixnum i))
35    (recursive-div2 l)
36    (recursive-div2 l)
37    (recursive-div2 l)
38    (recursive-div2 l)))
39