Logo

Programming-Idioms

History of Idiom 9 > diff from v26 to v27

Edit summary for version 27 by Dodopod:
New Scheme implementation by user [Dodopod]

Version 26

2017-02-07, 23:33:49

Version 27

2017-06-12, 15:33:41

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Code
(define (make-btree value left right)
  (cons value (cons left right)))

(define (btree-value bt) (car bt))
(define (btree-left bt) (cadr bt))
(define (btree-right bt) (cddr bt))