diff options
author | Colin Okay <cbeok@protonmail.com> | 2020-07-10 09:38:42 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-07-10 09:38:42 -0500 |
commit | 2048bea0524d89d21bd050d7f9bee7fc5defac95 (patch) | |
tree | 163151974bb8b4c2d736ef332421576dee81b202 | |
parent | 11985b09ea6efa6bbe70b5bc17c3251e51a7aed9 (diff) |
fixed dirtiness managment in inflate!, and skip-* combinators
-rw-r--r-- | gtwiwtg.lisp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gtwiwtg.lisp b/gtwiwtg.lisp index 6f977ac..cb1626f 100644 --- a/gtwiwtg.lisp +++ b/gtwiwtg.lisp @@ -426,8 +426,11 @@ Here is an example: Error Conditions: - If GEN has been used elsewhere, an error will be signalled. " - (sully-when-clean (list gen)) - (if (not (has-next-p gen)) gen + (sully-when-clean (list gen)) + (if (not (has-next-p gen)) + (progn + (setf (dirty-p gen) nil) + gen) (let ((sub-gen (funcall fn (next gen)))) (from-thunk-until (lambda () (next sub-gen)) @@ -524,8 +527,9 @@ Caveats: - It is possible that SKIP! will skip the whole source generator, returning an empty gernator. " + (sully-when-clean (list gen)) (dotimes (x n) (when (has-next-p gen) (next gen))) - (setf (slot-value gen 'dirty-p) nil) + (setf (dirty-p gen ) nil) gen) (defun skip-while! (pred gen) @@ -539,9 +543,10 @@ Caveat: the whole generated sequence. - 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 (slot-value gen 'dirty-p) nil) + (setf (dirty-p gen) nil) gen) |