Hi I am trying to transfer a binary tree to a list but crossing it in post-order.
(define (postorden arbol)
(if (null? arbol)
('()) (append (append (postorden (car (cdr arbol)))
(postorden (car (cddr arbol))))
(list (car arbol)))))
But I get this error:
cdr: contract violation expected: pair? given: 'null
But for example with this tree: '((1 2) ((7 10) ((2 4) null null)) ((6 8) ((10 13) null null) null))
performed the cdr and get: (((7 10) ((2 4) null null)) ((6 8) ((10 13) null nul) null)) and then I make the car to this outcome: '((7 10) ((2 4) null null)) which if it is a pair. So I do not understand what is wrong.
Thank you in advance.