diff --git a/flan-utils.lisp b/flan-utils.lisp index c10c27c..0e36978 100644 --- a/flan-utils.lisp +++ b/flan-utils.lisp @@ -121,7 +121,7 @@ while line do (funcall fi line))) - (defun map-lines (stream func &key + (defun map-lines (func stream &key (ignore nil) (applicator #'list) (mapper #'mapcar) @@ -151,31 +151,31 @@ The default behaviour (with `mapper' being `mapcar' and `applicator' being `list while (and line (funcall continue line)) collect (let ((line (funcall transform line))) (when (funcall filter-single-line line) line)))))))) - (defmacro map-file-lines (location func &rest kvs &key &allow-other-keys) + (defmacro map-file-lines (func location &rest kvs &key &allow-other-keys) "See `map-lines'(): Maps `func' over a file `location' instead of a stream." (let ((stream (gensym))) `(with-open-file (,stream ,location :direction :input) - ,(cons 'map-lines (append `(,stream ,func) kvs))))) + ,(cons 'map-lines (append `(,func ,stream) kvs))))) - (defun mapcan-lines (stream func &rest kvs &key &allow-other-keys) + (defun mapcan-lines (func stream &rest kvs &key &allow-other-keys) "See `map-lines'(): Uses `nconc'() as the applicator and `mapcar'() as the mapper, which produces an output you'd expect from `mapcan'() The other key arguments can be specified according to the signature of `map-lines'()." - (apply #'map-lines (append (list stream func :applicator #'nconc :mapper #'mapcar) kvs))) + (apply #'map-lines (append (list func stream :applicator #'nconc :mapper #'mapcar) kvs))) - (defmacro mapcan-file-lines (location func &rest kvs &key &allow-other-keys) + (defmacro mapcan-file-lines (func location &rest kvs &key &allow-other-keys) "See `mapcan-lines'(): Maps `func' over a file `location' instead of a stream." (let ((stream (gensym))) `(with-open-file (,stream ,location :direction :input) - ,(cons 'mapcan-lines (append `(,stream ,func) kvs))))) + ,(cons 'mapcan-lines (append `(,func ,stream) kvs))))) - (defun mapcon-lines (stream func &rest kvs &key &allow-other-keys) + (defun mapcon-lines (func stream &rest kvs &key &allow-other-keys) "See `map-lines'(): Uses `nconc'() as the applicator and `maplist'() as the mapper, which produces an output you'd expect from `mapcon'(). The other key arguments can be specified according to the signature of `map-lines'()." - (apply #'map-lines (append (list stream func :applicator #'nconc :mapper #'maplist) kvs))) + (apply #'map-lines (append (list func stream :applicator #'nconc :mapper #'maplist) kvs))) - (defmacro mapcon-file-lines (location func &rest kvs &key &allow-other-keys) + (defmacro mapcon-file-lines (func location &rest kvs &key &allow-other-keys) "See `mapcon-lines'(): Maps `func' over a file `location' instead of a stream." (let ((stream (gensym))) `(with-open-file (,stream ,location :direction :input) - ,(cons 'mapcon-lines (append `(,stream ,func) kvs))))) + ,(cons 'mapcon-lines (append `(,func ,stream) kvs))))) (defun strcat (&rest str) "Concat all strings, if item is not string it is written to one."