projects
/
jscl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
cfd9e0c
)
Add SATISFIES-TEST-P utility function, to be used by functions with key, test
author
Alfredo Beaumont
<alfredo.beaumont@gmail.com>
Wed, 15 May 2013 12:54:21 +0000
(14:54 +0200)
committer
Alfredo Beaumont
<alfredo.beaumont@gmail.com>
Wed, 15 May 2013 12:57:09 +0000
(14:57 +0200)
and test-not keyword arguments.
src/utils.lisp
patch
|
blob
|
history
diff --git
a/src/utils.lisp
b/src/utils.lisp
index
430b6a7
..
76b396d
100644
(file)
--- a/
src/utils.lisp
+++ b/
src/utils.lisp
@@
-84,3
+84,10
@@
(defun float-to-string (x)
#+jscl (float-to-string x)
#-jscl (format nil "~f" x))
+
+(defun satisfies-test-p (x y &key key (test #'eql) testp (test-not #'eql) test-not-p)
+ (when (and testp test-not-p)
+ (error "Both test and test-not are set"))
+ (let ((key-val (if key (funcall key y) y))
+ (fn (if test-not-p (complement test-not) test)))
+ (funcall fn x key-val)))