The attached patch addresses two issues:
1. COUNT-PERMUTATIONS now has type-checking and uses %MULTIPLY-RANGE, as was suggested in the comments.
2. SUBFACTORIAL now produces correct values. Previously, the values returned were incorrect starting with N = 12 or so. This was because the approximate value of e, produced by (exp 1), had insufficient precision be used in the [ n! / e ] formula for the subfactorial !n. Changing (exp 1) to (exp1.0d0) adds precision to e, but the problem still remained for N >= 14 or so. I reimplemented SUBFACTORIAL using the !n = n! * \sum_{k=0}^k{ \frac{ (-1)^k }{ k! } } formula to give exact results.
I also added tests for both of these functions.
In the near future, I'd like to open up a review of these functions (as well as the other combinatorics functions). Nikodemus suggested a couple of months ago that this should be done, but I wasn't sure if this was limited to Alexandria's main developers or open to everyone.
Mason
alexandria-devel@common-lisp.net