Created
August 22, 2025 13:17
-
-
Save lockie/7d541ec51bfeb99cd9007a975f85f32a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From bb3f74427d39dcd6f8b2b88c2cc81081ded65a2e Mon Sep 17 00:00:00 2001 | |
| From: Andrew Kravchuk <[email protected]> | |
| Date: Fri, 22 Aug 2025 15:06:29 +0200 | |
| Subject: [PATCH] Add compiler macro versions of DISJOIN & CONJOIN; closes #47 | |
| --- | |
| alexandria-1/functions.lisp | 15 +++++++++++++++ | |
| 1 file changed, 15 insertions(+) | |
| diff --git a/alexandria-1/functions.lisp b/alexandria-1/functions.lisp | |
| index dd83e38..43a874b 100644 | |
| --- a/alexandria-1/functions.lisp | |
| +++ b/alexandria-1/functions.lisp | |
| @@ -36,6 +36,14 @@ If none of the predicates returns true, NIL is returned." | |
| (apply p arguments)) | |
| more-predicates))))) | |
| +(define-compiler-macro disjoin (predicate &rest more-predicates) | |
| + `(lambda (&rest arguments) | |
| + (declare (optimize (speed 3) (safety 1) (debug 1)) | |
| + (dynamic-extent arguments)) | |
| + (or (apply ,predicate arguments) | |
| + ,@(loop for p in more-predicates | |
| + collect `(apply ,p arguments))))) | |
| + | |
| (defun conjoin (predicate &rest more-predicates) | |
| "Returns a function that applies each of PREDICATE and MORE-PREDICATE | |
| functions in turn to its arguments, returning NIL if any of the predicates | |
| @@ -54,6 +62,13 @@ predicates returns false, returns the primary value of the last predicate." | |
| (unless (apply head arguments) | |
| (return nil))))))) | |
| +(define-compiler-macro conjoin (predicate &rest more-predicates) | |
| + `(lambda (&rest arguments) | |
| + (declare (optimize (speed 3) (safety 1) (debug 1)) | |
| + (dynamic-extent arguments)) | |
| + (and (apply ,predicate arguments) | |
| + ,@(loop for p in more-predicates | |
| + collect `(apply ,p arguments))))) | |
| (defun compose (function &rest more-functions) | |
| "Returns a function composed of FUNCTION and MORE-FUNCTIONS that applies its | |
| -- | |
| 2.49.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment