10 - Define a recursive LISP function which takes 2
lists as arguments and returns a list containing alternate elements from each
list.
Implementation Code in LISP -
(defun alt ( A B)
(cond ((and (endp A) (endp B)) NIL)
((endp A) B)
((endp B) A)
(T (cons (car A) (alt B (cdr A))))))
OUTPUT-
(alt’(a b c d)’(1 2 3 4))
(A 1 B 2 C 3 D 4)
Implementation Code in LISP
(
(
((
((
(T (cons (car A) (
OUTPUT-
(alt’(a b c d)’(1 2 3 4))
(A 1 B 2 C 3 D 4)