spdegabrielle
2019-8-21 09:19:52

thongpv87
2019-8-21 14:25:27

@thongpv87 has joined the channel


thongpv87
2019-8-21 14:26:00

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


badkins
2019-8-21 15:13:01

I’m not sure I understand your question.


badkins
2019-8-21 15:17:26

See my recent mailing list post for context.


badkins
2019-8-21 15:28:31
#'(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))))>


badkins
2019-8-21 15:29:54

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


badkins
2019-8-21 15:30:40

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


badkins
2019-8-21 15:32:58

@thongpv87 ^


thongpv87
2019-8-21 15:45:09

Thanks you for the explanation