On 3/6/2011 12:23 PM, Barton Willis wrote:
> (1) Apparently, gcl 2.7 has a fix; see http://www.mail-archive.com/gcl-devel at gnu.org/msg01867.html
>
> (2) The function addk calls timeslk, but timeslk sends its arguments through *red. That's
> a bit inefficient, I think. Likely, there should be a test for the g = 1 case too.
>
> (3) This discussion is far removed from the CCL or GCL question for Windows.
> I don't have much of an opinion about that. But if I were trying to get
> cl-ppcre to work with Windows, likely I would favor CCL.
>
> --Barton
There are 2 things possible to do to fix addk. One requires no change
to addk.
Just change Maxima's representation of 1/2 from ((rat) 1 2) to the
lisp rational number 1/2.
Then the test for numberp on line 4 will just add the numbers. This
should be done anyway,
but may be tedious to check out.
Or add line 5 (or do both, just to be safe)
> (defun addk (xx yy)
> (cond ((equal xx 0) yy)
> ((equal yy 0) xx)
> ((and (numberp xx) (numberp yy)) (+ xx yy))
(( and (ratnump xx)(ratnump yy)) (/(+ (* (third
xx)(second yy))* (third yy)(second xx)))(* (third yy)(third xx))))
> ((or ($bfloatp xx) ($bfloatp yy)) ($bfloat (list '(mplus) xx yy)))
> (t (prog (g a b (x xx)(y yy))
> (cond ((numberp x)
> (cond ((floatp x) (return (+ x (fpcofrat y))))
> (t (setq x (list '(rat) x 1)))))
> ((numberp y)
> (cond ((floatp y) (return (+ y (fpcofrat x))))
> (t (setq y (list '(rat) y 1))))))
> (setq g (gcd (caddr x) (caddr y)))
> (setq a (truncate (caddr x) g)
> b (truncate (caddr y) g))
> (setq g (timeskl (list '(rat) 1 g)
> (list '(rat)
> (+ (* (cadr x) b)
> (* (cadr y) a))
> (* a b))))
> (return (cond ((numberp g) g)
> ((equal (caddr g) 1) (cadr g))
> ($float (fpcofrat g))
> (t g)))))))
(defun ratp(r)(and (consp r)(eq (caar r) 'rat)))