Changeset 5805
 Timestamp:
 02/13/04 08:34:24 (17 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/j/src/org/armedbear/lisp/lcm.lisp
r3694 r5805 2 2 ;;; 3 3 ;;; Copyright (C) 2003 Peter Graves 4 ;;; $Id: lcm.lisp,v 1. 1 20030911 01:44:15 pisoExp $4 ;;; $Id: lcm.lisp,v 1.2 20040213 08:34:24 asimon Exp $ 5 5 ;;; 6 6 ;;; This program is free software; you can redistribute it and/or … … 26 26 (/ (abs (* n m)) (gcd n m))))) 27 27 28 (defun lcm (&rest numbers)29 (unless (every #'integerp numbers)30 (error 'typeerror "arguments to LCM must be integers"))31 (case (length numbers)28 (defun lcm (&rest integers) 29 (unless (every #'integerp integers) 30 (error 'typeerror :datum (findifnot #'integerp integers) :expectedtype 'integer)) 31 (case (length integers) 32 32 (0 1) 33 (1 (abs (car numbers)))34 (2 (twoarglcm (car numbers) (cadr numbers)))33 (1 (abs (car integers))) 34 (2 (twoarglcm (car integers) (cadr integers))) 35 35 (t 36 (do ((result (car numbers) (twoarglcm result (car rest)))37 (rest (cdr numbers) (cdr rest)))36 (do ((result (car integers) (twoarglcm result (car rest))) 37 (rest (cdr integers) (cdr rest))) 38 38 ((null rest) result)))))
Note: See TracChangeset
for help on using the changeset viewer.