Subversion Repositories programming

Rev

Blame | Last modification | View Log | RSS feed

;;;
;;; A recursive function which takes two lists of integers and returns
;;; a list of integers in which each element is the sun of the
;;; corresponding elements of the incoming lists. The lists are
;;; not required to be the same length.
;;;
;;; Examples:
;;; (AL1 '(3 1 4) '(8 2 5)) --> (11 3 9)
;;; (AL1 '(3 1 4) '(2 2)) --> (5 3 4)
;;; (AL1 '(3 1 4) nil) --> (3 1 4)
;;;
(defun AL1 (L1 L2)
  (cond
    ((null L1) L2)
    ((null L2) L1)
    (t         (cons (+ (car L1) (car L2)) (AL1 (cdr L1) (cdr L2))))
  )
)