Mercurial > hg > xemacs-beta
comparison lisp/cl-extra.el @ 5226:7789ae555c45
Add Common Lisp's #'complement to cl-extra.el.
2010-06-02 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (complement):
* cl-extra.el (complement):
Add an implementation and a compiler macro for #'complement, as
specified by CL. For discussion; the compiler macro may be a
little too aggressive about taking the compile time argument lists
of the functions it is inverting.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 02 Jun 2010 16:18:50 +0100 |
parents | 2d0937dc83cf |
children | f3eca926258e |
comparison
equal
deleted
inserted
replaced
5225:1086297242fe | 5226:7789ae555c45 |
---|---|
97 | 97 |
98 ;; XEmacs; #'equalp is in C. | 98 ;; XEmacs; #'equalp is in C. |
99 | 99 |
100 ;; XEmacs; #'map, #'mapc, #'mapl, #'maplist, #'mapcon, #'some and #'every | 100 ;; XEmacs; #'map, #'mapc, #'mapl, #'maplist, #'mapcon, #'some and #'every |
101 ;; are now in C, together with #'map-into, which was never in this file. | 101 ;; are now in C, together with #'map-into, which was never in this file. |
102 | |
103 ;; The compiler macro for this in cl-macs.el means if #'complement is handed | |
104 ;; a constant expression, byte-compiled code will see a byte-compiled | |
105 ;; function. | |
106 (defun complement (function &optional documentation) | |
107 "Return a function which gives the logical inverse of what FUNCTION would." | |
108 `(lambda (&rest arguments) ,@(if documentation (list documentation)) | |
109 (not (apply ',function arguments)))) | |
102 | 110 |
103 (defun notany (cl-pred cl-seq &rest cl-rest) | 111 (defun notany (cl-pred cl-seq &rest cl-rest) |
104 "Return true if PREDICATE is false of every element of SEQ or SEQs." | 112 "Return true if PREDICATE is false of every element of SEQ or SEQs." |
105 (not (apply 'some cl-pred cl-seq cl-rest))) | 113 (not (apply 'some cl-pred cl-seq cl-rest))) |
106 | 114 |