bldc/tests/test_map_1.lisp

11 lines
254 B
Common Lisp
Raw Normal View History

(define map (lambda (f xs)
(let ((accmap (lambda (acc xs)
(if (= xs nil)
acc
(accmap (cons (f (car xs)) acc) (cdr xs))))))
(reverse (accmap nil xs)))))
(= (map (lambda (x) (+ x 1)) (list 1 2 3 4 5 6)) (list 2 3 4 5 6 7))