Scheme: Is it possible to convert a list of S-expressions into a list of atoms?
问题 I am trying to convert a list of S-expressions to a plain list of atoms similar to a problem in the book The Little Schemer . My code is (as typed in Dr.Racket): > (define lat '((coffee) cup ((tea) cup) (and (hick)) cup)) > (define f (lambda (lat) (cond ((null? lat) (quote ())) ((atom? (car lat)) (cons (car lat) (f (cdr lat)))) (else (cons (f (car lat)) (f (cdr lat))))))) > (f lat) '((coffee) cup ((tea) cup) (and (hick)) cup) The above code is returning back the list the same as input list. I