c2970d9e6ea7

Merge
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 14 Dec 2021 19:12:33 -0500
parents 95393d6a5226 (current diff) 656f2f6975bc (diff)
children 461876acdff5
branches/tags (none)
files src/iterate.lisp

Changes

--- a/losh.asd	Tue Dec 14 19:12:23 2021 -0500
+++ b/losh.asd	Tue Dec 14 19:12:33 2021 -0500
@@ -91,6 +91,7 @@
                              (:file "base")
                              (:file "arrays")
                              (:file "lists")
+                             (:file "iterate")
                              (:file "sequences")
                              (:file "control-flow")
                              (:file "ring-buffers"))))
--- a/src/iterate.lisp	Tue Dec 14 19:12:23 2021 -0500
+++ b/src/iterate.lisp	Tue Dec 14 19:12:33 2021 -0500
@@ -530,6 +530,7 @@
     (with-gensyms (r control skip)
       `(progn
          (with ,r = ,radius)
+         (with ,skip = ,should-skip-origin)
          ,@(mapcar (lambda (ovar oval)
                      `(with ,ovar = ,oval))
                    origin-vars origin-vals)
@@ -538,13 +539,11 @@
                                     (collect `(,var :from (- ,orig ,r) :to (+ ,orig ,r))))
                           :control-var ,control)
          (next ,control)
-         ,@(unless (null should-skip-origin)
-             `((with ,skip = ,should-skip-origin)
-               (when (and ,skip
-                          ,@(iterate (for var :in (ensure-list delta-vars))
-                                     (for ovar :in origin-vars)
-                                     (collect `(= ,ovar ,var))))
-                 (next ,control))))))))
+         (when (and ,skip
+                    ,@(iterate (for var :in (ensure-list delta-vars))
+                               (for ovar :in origin-vars)
+                               (collect `(= ,ovar ,var))))
+           (next ,control))))))
 
 
 (defmacro-driver (FOR var EVERY-NTH n DO form)
@@ -710,9 +709,11 @@
 
   "
   (if var
-    (let ((sep (gensym "SEP")))
+    (let ((separator% (gensym "SEPARATOR"))
+          (sep (gensym "SEP")))
       `(progn
-         (with ,sep = ,(if separator (string separator) ""))
+         (with ,separator% = ,separator)
+         (with ,sep = (if ,separator% (string ,separator%) ""))
          (reducing ,expr
                    :by (lambda (a b)
                          (if (null a)
@@ -720,11 +721,15 @@
                            (concatenate 'string a ,sep b)))
                    :into ,var
                    :initial-value nil)))
-    (let ((sos (gensym "SOS"))
+    (let ((separator% (gensym "SEPARATOR"))
+          (sos (gensym "SOS"))
           (sep (gensym "SEP")))
       `(progn
+         (with ,separator% = ,separator)
          (with ,sos = nil)
-         (with ,sep = ,(if separator (string separator) nil))
+         (with ,sep = (if (or (null ,separator%) (equal ,separator% ""))
+                        nil
+                        (string ,separator%)))
          (if (null ,sos)
            (setf ,sos (make-string-output-stream))
            (when ,sep