Hi,
I stumbled (probably due to some macro-expansion) over the following degenerate case of conjoin:
(funcall (conjoin #'zerop) 0)
It fails with NIL is not a function.
I propose the changes below (also attached as a darcs patch).
Cheers, Kilian
Thu Oct 15 16:42:45 CEST 2009 Kilian Sprotte kilian.sprotte@gmail.com * conjoin bug fix for single predicate argument diff -rN old-alexandria/functions.lisp new-alexandria/functions.lisp 40,49c40,51 < (lambda (&rest arguments) < (and (apply predicate arguments) < ;; Cannot simply use CL:EVERY because we want to return the < ;; non-NIL value of the last predicate if all succeed. < (do ((tail (cdr more-predicates) (cdr tail)) < (head (car more-predicates) (car tail))) < ((not tail) < (apply head arguments)) < (unless (apply head arguments) < (return nil)))))) ---
(if (null more-predicates) predicate (lambda (&rest arguments) (and (apply predicate arguments) ;; Cannot simply use CL:EVERY because we want to return the ;; non-NIL value of the last predicate if all succeed. (do ((tail (cdr more-predicates) (cdr tail)) (head (car more-predicates) (car tail))) ((not tail) (apply head arguments)) (unless (apply head arguments) (return nil)))))))
diff -rN old-alexandria/tests.lisp new-alexandria/tests.lisp 359a360,365
(deftest conjoin.2 (let ((conjunction (conjoin #'zerop))) (list (funcall conjunction 0) (funcall conjunction 1))) (t nil))
Hi,
just as a small reminder, could someone push the patch if it is ok?
Best, Kilian
Kilian Sprotte kilian.sprotte@gmail.com writes:
Hi,
I stumbled (probably due to some macro-expansion) over the following degenerate case of conjoin:
(funcall (conjoin #'zerop) 0)
It fails with NIL is not a function.
I propose the changes below (also attached as a darcs patch).
Cheers, Kilian
Thu Oct 15 16:42:45 CEST 2009 Kilian Sprotte kilian.sprotte@gmail.com
- conjoin bug fix for single predicate argument
diff -rN old-alexandria/functions.lisp new-alexandria/functions.lisp 40,49c40,51 < (lambda (&rest arguments) < (and (apply predicate arguments) < ;; Cannot simply use CL:EVERY because we want to return the < ;; non-NIL value of the last predicate if all succeed. < (do ((tail (cdr more-predicates) (cdr tail)) < (head (car more-predicates) (car tail))) < ((not tail) < (apply head arguments)) < (unless (apply head arguments)
< (return nil))))))
(if (null more-predicates) predicate (lambda (&rest arguments) (and (apply predicate arguments) ;; Cannot simply use CL:EVERY because we want to return the ;; non-NIL value of the last predicate if all succeed. (do ((tail (cdr more-predicates) (cdr tail)) (head (car more-predicates) (car tail))) ((not tail) (apply head arguments)) (unless (apply head arguments) (return nil)))))))
This looks ok. (Except that unified diffs are usually preferred.)
diff -rN old-alexandria/tests.lisp new-alexandria/tests.lisp 359a360,365
(deftest conjoin.2 (let ((conjunction (conjoin #'zerop))) (list (funcall conjunction 0) (funcall conjunction 1))) (t nil))
If you're at it, could you also provide similiar test cases for the other functions defined in functions.lisp?
-T.
Hi Tobias, hello everyone,
"Tobias C. Rittweiler" tcr@freebits.de writes:
If you're at it, could you also provide similiar test cases for the other functions defined in functions.lisp?
here is a new darcs patch that adds tests for all of DISJOIN, CONJOIN, COMPOSE and MULTIPLE-VALUE-COMPOSE.
It also includes the fix for CONJOIN from my last patch (which is now obsolete).
Cheers, Kilian
Kilian Sprotte kilian.sprotte@gmail.com writes:
Hi Tobias, hello everyone,
"Tobias C. Rittweiler" tcr@freebits.de writes:
If you're at it, could you also provide similiar test cases for the other functions defined in functions.lisp?
here is a new darcs patch that adds tests for all of DISJOIN, CONJOIN, COMPOSE and MULTIPLE-VALUE-COMPOSE.
It also includes the fix for CONJOIN from my last patch (which is now obsolete).
FWIW, from my part, this can be pushed now.
-T.
alexandria-devel@common-lisp.net