From 31a8affed35fa3442b11c1c62aa61e583f5bbef1 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 30 Jul 2008 11:31:42 +0200 Subject: Add DOLIST and MAPC. --- list-functions.lisp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/list-functions.lisp b/list-functions.lisp index 3660e5e..1912238 100644 --- a/list-functions.lisp +++ b/list-functions.lisp @@ -3,7 +3,7 @@ caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr car cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr - rest)) + rest mapc dolist)) (%defmacro* pushq args @@ -199,4 +199,20 @@ (sys::rplacd cons new-value)) +;;;;----------------------------------------------------------------- +;;;; ITERATION +;;;;----------------------------------------------------------------- +(defun mapc (function list) + ;;FIXME: Rewrite using TAGBODY. + (when list + (funcall function (first list)) + (mapc function (rest list)))) + +(defmacro dolist ((var list &optional result) &body body) + ;;FIXME: Rewrite using TAGBODY. + `(progn + (mapc (lambda (,var) ,@body) ,list) + ,result)) + + ;;;;----------------------------------------------------------------- -- cgit v1.2.3