Subversion Repositories programming

Rev

Rev 100 | Blame | Compare with Previous | Last modification | View Log | RSS feed

;Copyright: Ira W. Snyder
;Date: 07-11-2005
;License: Public Domain


;;;
;;; 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))))
  )
)