
Only 10 days left!
Get your entries in!
https://github.com/standard-fish/summer-competititon-2019/blob/master/README.md

@thongpv87 has joined the channel

I try to run this code from SICP book: (define (count-leaves x)
(cond ((null? x) 0)
((not (pair? x)) 1)
(else (+ (count-leaves (car x))
(count-leaves (cdr x))))))
(count-leaves '('(1 2) '(3 4)))
6
(count-leaves '((1 2) '(3 4)))
5
How can I explain the result

I’m not sure I understand your question.

See my recent mailing list post for context.

#'(count-leaves '('(1 2) '(3 4)))
#'(count-leaves '((1 2) '(3 4)))
#'(count-leaves '((1 2) (3 4)))
displays: .#<syntax:unsaved-editor:9:2 (count-leaves (quote ((quote (1 2)) (quote (3 4)))))>
.#<syntax:unsaved-editor:11:2 (count-leaves (quote ((1 2) (quote (3 4)))))>
.#<syntax:unsaved-editor:13:2 (count-leaves (quote ((1 2) (3 4))))>

IIUC the leaves in the first example are: quote
1
2
quote
3
4
==> 6 leaves

… in the second: 1
2
quote
3
4
==> 5 leaves … in the third: 1
2
3
4
=> 4 leaves

@thongpv87 ^

Thanks you for the explanation