From 32590769af28a3c571945b2c6ae5256e9dc64b45 Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 20 Mar 2022 15:26:55 +0000 Subject: [PATCH] Fixed order of arguments in `map-lines()` and relations functions/macros to be consistent with CL standard `map*()` functions (`function source" instead of `source function".) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for cl-utils's current commit: Middle blessing − 中吉 --- flan-utils.lisp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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."