Logo

Programming-Idioms

History of Idiom 17 > diff from v32 to v33

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

Version 32

2017-05-27, 20:12:09

Version 33

2017-06-12, 15:38:52

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Code
(define (make-tree value children)
  (cons value children))

(define (tree-value t) (car t))
(define (tree-first-child t) (cadr t))
(define (tree-rest-children t) (cddr t))
Comments bubble
children is list of trees