Two-Way Recursive Functions
> (defun censor2 (lst)
"Returns LST with no instances of BAD."
(cond ((null lst) nil)
((atom lst) lst)
((eq (car lst) 'BAD)
(censor2 (rest lst)) )
(t (cons (censor2 (car lst))
(censor2 (rest lst)) ) ) ) )
CENSOR2
> (censor2 '(This bad list (has a bad sublist)))
(THIS LIST (HAS A SUBLIST))
Previous slide
Next slide
Back to first slide
View graphic version