1 665c255d 2023-08-04 jrmu (define (count-leaves x)
2 665c255d 2023-08-04 jrmu (cond ((null? x) 0)
3 665c255d 2023-08-04 jrmu ((not (pair? x)) 1)
4 665c255d 2023-08-04 jrmu (else (+ (count-leaves (car x))
5 665c255d 2023-08-04 jrmu (count-leaves (cdr x))))))
7 665c255d 2023-08-04 jrmu ;;(list 1 (list 2 (list 3 4)))
8 665c255d 2023-08-04 jrmu ;;'(1 (2 (3 4)))
10 665c255d 2023-08-04 jrmu ;; Exercise 2.26. Suppose we define x and y to be two lists:
12 665c255d 2023-08-04 jrmu (define x (list 1 2 3))
13 665c255d 2023-08-04 jrmu (define y (list 4 5 6))
15 665c255d 2023-08-04 jrmu ;; What result is printed by the interpreter in response to evaluating each of the following expressions:
17 665c255d 2023-08-04 jrmu (display (append x y))
19 665c255d 2023-08-04 jrmu (display '(1 2 3 4 5 6))
23 665c255d 2023-08-04 jrmu (display (cons x y))
25 665c255d 2023-08-04 jrmu (display '((1 2 3) 4 5 6))
29 665c255d 2023-08-04 jrmu (display (list x y))
31 665c255d 2023-08-04 jrmu (display '((1 2 3) (4 5 6))