[alexandria-devel] conjoin bug fix
Kilian Sprotte
kilian.sprotte at gmail.com
Thu Oct 15 14:49:02 UTC 2009
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 at 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))
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: conjoin.patch
Type: text/x-patch
Size: 19404 bytes
Desc: conjoin patch
URL: <https://mailman.common-lisp.net/pipermail/alexandria-devel/attachments/20091015/dab5f4cc/attachment.bin>
-------------- next part --------------
--
Kilian Sprotte
10405 Berlin
More information about the alexandria-devel
mailing list