How to find the maximum nesting depth of a S-expression in scheme?
问题 for example (nestFind '(a(b)((c))d e f)) => 3 (nestFind '()) => 0 (nestFind '(a b)) => 1 (nestFind '((a)) )=> 2 (nestFind '(a (((b c d))) (e) ((f)) g)) => 4 this is what i tried so far but its not working properly: (define (nestFind a) (cond ((null? a)0) ((atom? a)0) ((atom? (car a))(+ 1 (nestFind (cdr a)))) (else (+(nestFind (car a))(nestFind (cdr a)))))) 回答1: It's a bit simpler. Give this a try: (define (nestFind lst) (if (not (pair? lst)) 0 (max (add1 (nestFind (car lst))) (nestFind (cdr