[movitz-cvs] CVS update: movitz/losp/muerte/integers.lisp
Frode Vatvedt Fjeld
ffjeld at common-lisp.net
Wed May 19 15:42:08 UTC 2004
Update of /project/movitz/cvsroot/movitz/losp/muerte
In directory common-lisp.net:/tmp/cvs-serv1920
Modified Files:
integers.lisp
Log Message:
Added floor.
Date: Wed May 19 11:42:08 2004
Author: ffjeld
Index: movitz/losp/muerte/integers.lisp
diff -u movitz/losp/muerte/integers.lisp:1.9 movitz/losp/muerte/integers.lisp:1.10
--- movitz/losp/muerte/integers.lisp:1.9 Wed May 19 11:09:05 2004
+++ movitz/losp/muerte/integers.lisp Wed May 19 11:42:08 2004
@@ -9,7 +9,7 @@
;;;; Created at: Wed Nov 8 18:44:57 2000
;;;; Distribution: See the accompanying file COPYING.
;;;;
-;;;; $Id: integers.lisp,v 1.9 2004/05/19 15:09:05 ffjeld Exp $
+;;;; $Id: integers.lisp,v 1.10 2004/05/19 15:42:08 ffjeld Exp $
;;;;
;;;;------------------------------------------------------------------
@@ -1132,3 +1132,19 @@
(gcd gcd (car rest)))
(rest (cdr numbers) (cdr rest)))
((null rest) gcd)))))
+
+(defun floor (n &optional (divisor 1))
+ "This is floor written in terms of truncate."
+ (numargs-case
+ (1 (n) n)
+ (2 (n divisor)
+ (multiple-value-bind (q r)
+ (truncate n divisor)
+ (cond
+ ((<= 0 q)
+ (values q r))
+ ((= 0 r)
+ (values q 0))
+ (t (values (1- q) (+ r divisor))))))
+ (t (n &optional (divisor 1))
+ (floor n divisor))))
\ No newline at end of file
More information about the Movitz-cvs
mailing list