[plt-scheme] Help: I want to travel a binary tree?

From: Grant Rettke (grettke at acm.org)
Date: Tue Jul 31 11:29:41 EDT 2007

;Hi Zeng Fucen,

;Fill in the blank for the "visit" function

; You should read The Little Schemer, it would help with stuff like this

(define top car)

(define left cadr)

(define right caddr)

(define (left? ntt)
    (check ntt left))

(define (right? ntt)
  (check ntt right))

(define (check ntt op)
  (cond
    [(> (length ntt) 1) (op ntt)]
    [else #f]))

(define (visit ntt)
    ...)

(define tree '(O (J) (E (K) (R))))

(visit tree)

JOKER


Posted on the users mailing list.