Changeset 4539
- Timestamp:
- 2016-06-18T17:14:19-07:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/slow-add.lisp
r4538 r4539 35 35 (t 36 36 (rotatef (cdr q) r q)))))) 37 38 (defun s-add (p q order-fn add-fn &aux result)39 "Non-recursive version of SLOW-ADD. This version uses auxillary variable40 RESULT which serves as a stack for the terms of the sum of P and Q."41 (loop42 (cond43 ((endp p) (return-from s-add (nreconc result q)))44 ((endp q) (return-from s-add (nreconc result p)))45 (t46 (multiple-value-bind47 (greater-p equal-p)48 (funcall order-fn (car p) (car q))49 (cond50 (greater-p ; (> (car p) (car q))51 (push (pop p) result)52 )53 (equal-p ; (= (car p)) (car q))54 (let ((s (funcall add-fn (lc p) (lc q))))55 (cond56 ((universal-zerop s)57 (pop p))58 (t59 ;; Adjust the lc of p60 (setf (lc p) s)61 (push (pop p) result)62 )63 ))64 (pop q)65 )66 (t ;(< (car p) (car q))67 (push (pop q) result)68 )69 ))))))
Note:
See TracChangeset
for help on using the changeset viewer.