41 lines
847 B
Scheme
41 lines
847 B
Scheme
|
(load "util.scm")
|
||
|
|
||
|
(display "\nex-2.24\n")
|
||
|
|
||
|
(define x (cons (list 1 2) (list 3 4)))
|
||
|
|
||
|
(define (display-spaces n)
|
||
|
(cond ((= n 0) ())
|
||
|
(else (display " ") (display-spaces (- n 1)))))
|
||
|
|
||
|
; Procedure to print a tree (in an ugly way)
|
||
|
(define (display-tree tree level)
|
||
|
(if (null? tree)
|
||
|
()
|
||
|
(cond
|
||
|
((pair? (car tree))
|
||
|
(display-spaces level) (display tree) (newline)
|
||
|
(display-spaces (+ level 1)) (display (car tree)) (newline)
|
||
|
(display-tree (car tree) (+ level 1))
|
||
|
(display-tree (cdr tree) level))
|
||
|
(else
|
||
|
(display-spaces level)
|
||
|
(display (car tree))
|
||
|
(newline)
|
||
|
(display-tree (cdr tree) level)))))
|
||
|
|
||
|
(display-tree x 0)
|
||
|
|
||
|
|
||
|
(display "\nex-2.25\n")
|
||
|
|
||
|
(display "\nex-2.26\n")
|
||
|
|
||
|
(display "\nex-2.27\n")
|
||
|
|
||
|
(display "\nex-2.28\n")
|
||
|
|
||
|
(display "\nex-2.29\n")
|
||
|
|
||
|
(display "\nex-2.30\n")
|