next up previous contents index
Next: Initializing the A++ Interpreter Up: Initializing the A++ Interpreter Previous: Initializing the A++ Interpreter   Contents   Start

Initializing the A++ Interpreter part 6



(define insert (lambda(x l)
                 (if (nullp l)
                      (cons x nil)
                      (if (ltp x (car l))
                          (cons x l)
                          (cons (car l) (insert x (cdr l)))))))
;
(define insertion-sort (lambda(l)
                         (if (nullp l)
                             nil
                             (insert (car l) (insertion-sort (cdr l))))))
;
(define sum (lambda(l)
              (if (nullp l)
                  zero
                  (add (car l) (sum (cdr l))))))
;
(define for-each (lambda(procedure lis)
                   (if (nullp lis)
                       true
                       ((lambda()
                          (procedure (car lis))
                          (for-each procedure (cdr lis)))))))
(define nth    (lambda(n l)
                 (if (equaln n one)
                     (car l)
                     (nth (sub n one) (cdr l)))))
;



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz