From 07da35c5e99ed9604540d76455330c1e8734b411 Mon Sep 17 00:00:00 2001 From: Alfredo Beaumont Date: Wed, 15 May 2013 14:54:21 +0200 Subject: [PATCH] Add SATISFIES-TEST-P utility function, to be used by functions with key, test and test-not keyword arguments. --- src/utils.lisp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils.lisp b/src/utils.lisp index 430b6a7..76b396d 100644 --- 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))) -- 1.7.10.4