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(a)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))
>
--
Kilian Sprotte
10405 Berlin