" The function flatten takes in as input a list and returns " " a flat list consisting of all the atoms present in the list " (defun flatten (lst) (if (null lst) lst (if (atom (car lst)) (append (list (car lst)) (flatten (cdr lst))) (append (flatten (car lst)) (flatten (cdr lst))) ) ) ) (defun factorial (n) (if (= n 0) 1 (* n (factorial (- n 1))) ) ) (defun count_atoms (lst) (if (null lst) 0 (if (atom (car lst)) (+ 1 (count_atoms (cdr lst))) (+ (count_atoms (car lst)) (count_atoms (cdr lst))) ) ) ) (defun apply_subst (x y lst) (if (null lst) '() (if (equal y (car lst)) (cons x (apply_subst x y (cdr lst))) (if (atom (car lst)) (cons (car lst) (apply_subst x y (cdr lst))) (cons (apply_subst x y (car lst)) (apply_subst x y (cdr lst))) ) ) ) )