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 4




(define curry  (lambda(f)
                 (lambda(x)
                   (lambda(y)
                     (f x y)))))
;
(define map    (lambda(f l)
                 (if (nullp l)
                     nil
                     (cons (f (car l)) (map f (cdr l))))))
;
(define filter (lambda(p l)
                 (if (nullp l)
                     nil
                     (if (p (car l))
                         (cons (car l) (filter p (cdr l)))
                         (filter p (cdr l))))))
;
(define locate (lambda(pred l)
                 (if (nullp l)
                     false
                     (if (pred (car l))
                         true
                         (locate pred (cdr l))))))
;
(define locatex (lambda(pred l)
                  (if (nullp l)
                      false
                      (if (pred (car l))
                          (car l)
                          (locatex pred (cdr l))))))
;
(define remove (lambda(obj l)
                 (if (nullp l)
                     nil
                     (if (equalx obj (car l))
                         (remove obj (cdr l))
                         (cons (car l)  (remove obj (cdr l)))))))
;
(define mapc   (curry map))
(define succ*  (mapc succ))
;



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz