(progn (load "../l1") (load "../h1") (load "components") ) ;(setq l (comp_4_2 '((a1 b1 ) (a2 b2 c2 d2 )))) ;(print-list l) (defun comp_4_2 (l) (let ((out '()) (comp '()) (lastcout '()) (p 0)) (mapcar (function (lambda (a) (let ((v '()) (e '())) (setq v (copy-without-nil (append a (list lastcout)))) (cond ((eq (length v) 5) (setq e (gen-4-2 (nth 0 v) (nth 1 v) (nth 2 v) (nth 3 v) (nth 4 v))) (setq comp (cons e comp)) (setq out (add-in out p (get-output e "osum"))) (setq out (add-in out (+ p 1) (get-output e "ocarry"))) (setq lastcout (get-output e "ocout")) ) ((eq (length v) 4) (setq e (gen-4-2 (nth 0 v) (nth 1 v) (nth 2 v) (nth 3 v) 0)) (setq comp (cons e comp)) (setq out (add-in out p (get-output e "osum"))) (setq out (add-in out (+ p 1) (get-output e "ocarry"))) (setq lastcout (get-output e "ocout")) ) ((eq (length v) 3) (setq e (gen-fa (nth 0 v) (nth 1 v) (nth 2 v))) (setq comp (cons e comp)) (setq out (add-in out p (get-output e "osum"))) (setq lastcout (get-output e "ocout")) ) ((eq (length v) 2) (setq out (add-in out p (nth 0 v))) (setq out (add-in out p (nth 1 v))) ) ((eq (length v) 1) (setq out (add-in out p (nth 0 v))) ) ((eq (length v) 0) ) (t (error "unavailable")) ) (setq p (+ p 1)) ))) l) `(,comp ,out) ) )