Skip to content
Browse files

shadchen update

  • Loading branch information...
1 parent db65497 commit f11b91382e1342b6da8f03571cdd4ac249cf023b @VincentToups committed Jan 16, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 shadchen.el
View
15 shadchen.el
@@ -186,5 +186,20 @@ An error is thrown when no matches are found."
(let ((name (gensym "MATCH-LAMBDA-NAME-")))
`(function (lambda (,name) (match ,name ,@forms)))))
+(defun length=1 (lst)
+ "Returns T when LST has one element."
+ (and (consp lst)
+ (not (cdr lst))))
+
+(defpattern list-rest (&rest patterns)
+ (if (length=1 patterns)
+ `(? #'listp ,(car patterns))
+ (let ((pat (car patterns))
+ (pats (cdr patterns)))
+ `(and (funcall #'car ,pat)
+ (funcall #'cdr
+ (list-rest ,@pats))))))
+
+
(provide 'shadchen)

0 comments on commit f11b913

Please sign in to comment.
Something went wrong with that request. Please try again.