23.03.2013 Views

Performance and Evaluation of Lisp Systems - Dreamsongs

Performance and Evaluation of Lisp Systems - Dreamsongs

Performance and Evaluation of Lisp Systems - Dreamsongs

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

146<br />

3.8 Destructive<br />

3.8.1 The Program<br />

;;; DESTRU -- Destructive operation benchmark<br />

(defun destructive (n m)<br />

(let ((l (do ((i 10. (1- i))<br />

(a () (push () a)))<br />

((= i 0) a))))<br />

(do ((i n (1- i)))<br />

((= i 0))<br />

(cond ((null (car l))<br />

(do ((l l (cdr l)))<br />

((null l))<br />

(or (car l)<br />

(rplaca l (cons () ())))<br />

(nconc (car l)<br />

(do ((j m (1- j))<br />

(a () (push () a)))<br />

((= j 0) a)))))<br />

(t<br />

(do ((l1 l (cdr l1))<br />

(l2 (cdr l) (cdr l2)))<br />

((null l2))<br />

(rplacd (do ((j (floor (length (car l2)) 2)<br />

(1- j))<br />

(a (car l2) (cdr a)))<br />

((zerop j) a)<br />

(rplaca a i))<br />

(let ((n (floor (length (car l1)) 2)))<br />

(cond ((= n 0) (rplaca l1 ())<br />

(car l1))<br />

(t<br />

(do ((j n (1- j))<br />

(a (car l1) (cdr a)))<br />

((= j 1)<br />

(prog1 (cdr a)<br />

(rplacd a ())))<br />

(rplaca a i))))))))))))<br />

;;; call: (destructive 600. 50.)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!