【发布时间】:2014-05-06 21:48:22
【问题描述】:
例如
(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
这是我迄今为止尝试过的,但它不能正常工作:
(define (nestFind a)
(cond
((null? a)0)
((atom? a)0)
((atom? (car a))(+ 1 (nestFind (cdr a))))
(else
(+(nestFind (car a))(nestFind (cdr a))))))
【问题讨论】:
标签: functional-programming scheme lisp racket