Skip to content

Instantly share code, notes, and snippets.

@cametan001
Created July 24, 2010 17:05
Show Gist options
  • Select an option

  • Save cametan001/488816 to your computer and use it in GitHub Desktop.

Select an option

Save cametan001/488816 to your computer and use it in GitHub Desktop.
;; P54A (*) Check whether a given term represents a binary tree
;; Write a predicate istree which returns true if and only if its argument is a list representing a binary tree.
;; Example:
;; * (istree (a (b nil nil) nil))
;; T
;; * (istree (a (b nil nil)))
;; NIL
(define (istree? lst)
(or (null? lst)
(and (= (length lst) 3)
(istree? (cadr lst))
(istree? (caddr lst)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment