next up previous contents
Next: Object Oriented Programming in Up: Miscellaneous abstractions Previous: Miscellaneous abstractions   Contents


Testing the basic abstractions


(define l1
   (cons four (cons three (cons two (cons one nil)))))
;;;;;
(ndisp! (length l1))
;;;;;                 --> 4
(ldisp! l1)
;;;;;                 --> 4
;;;;;                     3
;;;;;                     2
;;;;;                     1
;(insertion-sort l1)
(ldisp! (insertion-sort l1))
;;;;;                 --> 1
;;;;;                     2
;;;;;                     3
;;;;;                     4
(ndisp! (sum l1))
;;;;;                 --> 10
(succ* l1)
(ldisp! (succ* l1))
;;;;;                 --> 5
;;;;;                     4
;;;;;                     3
;;;;;                     2
(filter (lambda(x) (gtp x two)) l1)
(ldisp! (filter (lambda(x) (gtp x two)) l1))
;;;;;                 --> 4
;;;;;                     3          
(define l1 (cons one (cons three (cons four nil))))
;
(define l2 (cons seven (cons eight (cons nine (cons ten nil)))))
;
(ndisp! (faculty five))
;;;;;                 -->120
(ndisp! (nth two l1))
;;;;;                 -->3
(for-each ndisp! l2)
;;;;;                 -->7
;;;;;                    8
;;;;;                    9
;;;;;                    10
(define while-test
  (lambda(n)
    (while (gtp n zero)
      (lambda()
        (define n (pred n))
        (ndisp! n)))))
;
(while-test ten)
;;;;;                 -->10
;;;;;                    9
;;;;;                    8
;;;;;                    7
;;;;;                    6
;;;;;                    5
;;;;;                    4
;;;;;                    3
;;;;;                    2
;;;;;                    1



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz