[elephant-cvs] CVS elephant/src/utils

ieslick ieslick at common-lisp.net
Tue Mar 6 04:15:27 UTC 2007


Update of /project/elephant/cvsroot/elephant/src/utils
In directory clnet:/tmp/cvs-serv27096/utils

Modified Files:
	convenience.lisp package.lisp 
Log Message:
Placeholders and notes for query engine

--- /project/elephant/cvsroot/elephant/src/utils/convenience.lisp	2007/03/03 17:25:00	1.4
+++ /project/elephant/cvsroot/elephant/src/utils/convenience.lisp	2007/03/06 04:15:27	1.5
@@ -45,3 +45,27 @@
   (let ((results (car list)))
     (dolist (elem (cdr list) results)
       (setq results (append results elem)))))
+
+(defmacro ifret (pred alt)
+  "If pred is non-null, return the value, otherwise return the alternate value"
+  (with-gensyms (res)
+  `(let ((,res ,pred))
+     (if ,res ,res ,alt))))
+
+(defmacro aif (pred default alt)
+  "Anaphoric if"
+  `(let ((it ,pred))
+     (if it ,default ,alt)))
+
+(defmacro awhen (pred &rest body)
+  "Anaphoric when"
+  `(let ((it ,pred))
+     (declare (ignorable it))
+     (when it
+       , at body)))
+
+(defun mklist (elts)
+  "Make sure the argument is a list or 
+   make it a list if it's an atom"
+  (if (listp elts) elts (list elts)))
+
--- /project/elephant/cvsroot/elephant/src/utils/package.lisp	2007/02/24 14:52:00	1.4
+++ /project/elephant/cvsroot/elephant/src/utils/package.lisp	2007/03/06 04:15:27	1.5
@@ -32,4 +32,9 @@
    #:do-subsets
    #:subsets
    #:remove-keywords
-   #:with-gensyms))
+   #:with-gensyms
+   #:ifret
+   #:aif
+   #:awhen
+   #:mklist
+   #:it))




More information about the Elephant-cvs mailing list