aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtwiwtg.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'gtwiwtg.lisp')
-rw-r--r--gtwiwtg.lisp14
1 files changed, 10 insertions, 4 deletions
diff --git a/gtwiwtg.lisp b/gtwiwtg.lisp
index 43e0274..18b32c4 100644
--- a/gtwiwtg.lisp
+++ b/gtwiwtg.lisp
@@ -564,10 +564,16 @@ Caveat:
- If the generator is infinite, then skip-while! MIGHT never return.
"
(sully-when-clean (list gen))
- (loop :while (and (has-next-p gen)
- (funcall pred (next gen))))
- (setf (dirty-p gen) nil)
- gen)
+ (let ((cached (list nil)))
+ (loop
+ :while (has-next-p gen)
+ :for val = (next gen)
+ :unless (funcall pred val)
+ :do
+ (setf (car cached) val)
+ (return))
+ (setf (dirty-p gen) nil)
+ (concat! (seq cached) gen)))
(defun nfurcate! (count source-generator)