[cl-utilities-cvs] CVS update: cl-utilities/expt-mod.lisp
Peter Scott
pscott at common-lisp.net
Mon May 9 21:51:32 UTC 2005
Update of /project/cl-utilities/cvsroot/cl-utilities
In directory common-lisp.net:/tmp/cvs-serv22187
Modified Files:
expt-mod.lisp
Log Message:
Added support for non-integer arguments on Lisps other than SBCL.
Date: Mon May 9 23:51:31 2005
Author: pscott
Index: cl-utilities/expt-mod.lisp
diff -u cl-utilities/expt-mod.lisp:1.1.1.1 cl-utilities/expt-mod.lisp:1.2
--- cl-utilities/expt-mod.lisp:1.1.1.1 Mon May 9 23:26:29 2005
+++ cl-utilities/expt-mod.lisp Mon May 9 23:51:31 2005
@@ -9,12 +9,14 @@
;; compiler to optimize it. This may be the case on other Lisp
;; implementations as well.
#+sbcl (mod (expt n exponent) modulus)
- #-sbcl (loop with result = 1
- for i of-type fixnum from 0 below (integer-length exponent)
- for sqr = n then (mod (* sqr sqr) modulus)
- when (logbitp i exponent) do
- (setf result (mod (* result sqr) modulus))
- finally (return result)))
+ #-sbcl (if (some (complement #'integerp) (list n exponent modulus))
+ (mod (expt n exponent) modulus)
+ (loop with result = 1
+ for i of-type fixnum from 0 below (integer-length exponent)
+ for sqr = n then (mod (* sqr sqr) modulus)
+ when (logbitp i exponent) do
+ (setf result (mod (* result sqr) modulus))
+ finally (return result))))
;; If SBCL is going to expand compiler macros, we should directly
;; inline the simple expansion; this lets SBCL do all sorts of fancy
More information about the Cl-utilities-cvs
mailing list