Perfect Shuffle of 2 Lists

Write a CLisp Program that will:
1. Compute the length of a given list. Your program should handle lists of various sizes.
2. Compute the second to last element of a given list. Your program should handle lists of varioussizes.
3. Take two lists, L1 and L2, of same lengths and will return a merged list, L3, such that L3 is
obtained by carrying out the perfect shuffle operation on L1 and L2. Your program should
handle lists of various sizes. (Note: A perfect shuffle on two lists, [1, 2] and [3, 4], will result in [1,3, 2, 4].)

Solution

(defun my-length (lst)

(if (null lst)

0

(+ 1 (my-length (cdrlst)))

)

)

(defun my-last (lst)

(if (null (cdrlst))

(if (atom (car lst))

(carlst)

(my-last (car lst))

)

(my-last (cdrlst))

)

)

(defun second-to-last (lst)

(if (and (null (cdrlst)) (not (atom (car lst))))

(second-to-last (car lst))

(if (null (cdr (cdrlst)))

(if (atom (car (cdrlst)))

(if (atom (car lst))

(carlst)

(my-last (car lst))

)

(second-to-last (car (cdrlst)))

)

(second-to-last (cdrlst))

)

)

)

(defun perfect-shuffle (lst1 lst2)

(if (null lst1)

lst1

(cons (car lst1) (cons (car lst2) (perfect-shuffle (cdr lst1) (cdr lst2))))

)

)