Created
July 24, 2010 17:05
-
-
Save cametan001/488816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 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