Add #'effector and #'empty-or-nil-p.
This commit is contained in:
parent
6e932bea6a
commit
098ffbdc41
17
kutils.lisp
17
kutils.lisp
|
@ -133,3 +133,20 @@ contain any additional keyword arguments to @c(assoc)."
|
||||||
(cons x y))
|
(cons x y))
|
||||||
b))
|
b))
|
||||||
a)))
|
a)))
|
||||||
|
|
||||||
|
(defun empty-or-nil-p (arg)
|
||||||
|
"Is @c(arg) null, or does it represent an empty sequence? Returns
|
||||||
|
NIL if @c(arg) is not a nil or a sequence."
|
||||||
|
(cond ((null arg) t)
|
||||||
|
((stringp arg) (string-equal "" arg))
|
||||||
|
((vectorp arg) (zerop (length arg)))
|
||||||
|
((listp arg) (null (rest arg)))
|
||||||
|
(t nil)))
|
||||||
|
|
||||||
|
(defun effector (&rest fns)
|
||||||
|
"An effector returns a function that calls all the functions
|
||||||
|
supplied to @c(effector) on its input. This is usually useful for
|
||||||
|
effectful code, such as logging."
|
||||||
|
(lambda (&rest args)
|
||||||
|
(dolist (fn fns)
|
||||||
|
(apply fn args))))
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#:extend-vector
|
#:extend-vector
|
||||||
#:assoc-val
|
#:assoc-val
|
||||||
#:cartprod2
|
#:cartprod2
|
||||||
|
#:empty-or-nil-p
|
||||||
|
#:effector
|
||||||
|
|
||||||
;; kutils-hash-tables.lisp
|
;; kutils-hash-tables.lisp
|
||||||
#:enable-hash-table-reader
|
#:enable-hash-table-reader
|
||||||
|
|
Loading…
Reference in New Issue