freeof, was: Re: [Maxima] Mock-up html manual page
Subject: freeof, was: Re: [Maxima] Mock-up html manual page
From: Robert Dodier
Date: Thu, 27 Jan 2005 22:12:37 -0800 (PST)
I've made some slight modifications to the code which Stavros posted.
I haven't found anything broken but maybe someone else can try.
Incidentally since freeof is used in various contexts, run_testsuite()
causes it to be called a number of times -- after pasting in the
modified freeof, the only tests which fail are 2 which fail anyway
(52 and 60 in rtest14.mac).
Here are some example outputs --
freeof(x,'('integrate(1,x,0,y))) => T OK
freeof(x,'(integrate(1,x,0,y))) => T OK
freeof(y,'(integrate(1,x,0,y))) => F OK
freeof(x,'(integrate(integrate(1,x,0,y),y,0,z))) => T OK
freeof(y,'(integrate(integrate(1,x,0,y),y,0,z))) => T OK
freeof(z,'(integrate(integrate(1,x,0,y),y,0,z))) => F OK
freeof (x, y, z, 'lambda ([x, y], x*y*lambda ([z], z))) => T OK
freeof (w, 'lambda ([x, y], x*y*lambda ([z], w*z))) => F OK
freeof (x, y, z, 'block ([x, y], x*y*block ([z], z))) => T OK
freeof (w, 'block ([x, y], x*y*block ([z], w*z))) => F OK
freeof (x, y, z, '([x, y], x*y* ([z], w*z))) => T OK
freeof (w, '([x, y], x*y* ([z], w*z))) => F OK
Here's the code in question.
(defun freeof (var e)
(cond ((alike1 var e) nil)
((atom e) t)
((and (not argsfreeofp) (alike1 var (caar e))) nil)
((and (or (memq (caar e) '(%product %sum %laplace
$product $sum $laplace))
(and (memq (caar e) '(%integrate $integrate))
(cdddr e))
(and (memq (caar e) '(%limit $limit)) (cddr e)))
(alike1 var (caddr e)))
(freeofl var (cdddr e)))
((memq (caar e) '(%at $at))
(cond ((not (freeofl var (hand-side (caddr e) 'r))) nil)
((not (freeofl var (hand-side (caddr e) 'l))) t)
(t (freeof var (cadr e)))))
((and (eq (caar e) 'lambda) (memq var (cdadr e))) t)
((and (or (eq (caar e) 'mprog) (eq (caar e) 'mprogn)) ($listp
(cadr e))
(mapor (lambda (binding)
(if (atom binding)
(eq binding var)
(and (eq (caar binding) 'msetq)
(eq (cadr binding) var))))
(cdadr e))) t)
(argsfreeofp (freeofl var (margs e)))
(t (freeofl var (cdr e)))))
For what it's worth,
Robert Dodier
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail