commit 73d26a0f42b90cc78454d78672e79d0877dd2faf parent fe0c1f72716eb44faeaea141066e1a02e8296195 Author: Tomas Hlavaty <tom@logand.com> Date: Fri, 20 Oct 2017 19:41:33 +0200 add flat-reader Diffstat:
M | rw.lisp | | | 15 | +++++++++++++++ |
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/rw.lisp b/rw.lisp @@ -557,3 +557,18 @@ (defun wrap-writer (writer fn) (lambda (x) (funcall writer (funcall fn x)))) + +(defun flat-reader (reader) + (let ((r (list reader))) + (lambda () + (loop + (unless r + (return)) + (let ((z (funcall (car r)))) + (if z + (if (functionp z) + (push z r) + (return z)) + (pop r))))))) + +;;(slurp (flat-reader (reader (list (reader (list 1 2)) (reader (list (reader (list 3 4)) 5))))))