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".)

Fortune for cl-utils's current commit: Middle blessing − 中吉
master
Avril 3 years ago
parent c90a17fd4d
commit 32590769af
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -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."

Loading…
Cancel
Save