From: Rupert S. <rsw...@us...> - 2013-07-01 20:57:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Maxima CAS". The branch, master has been updated via 24090c3954b1de0e313318e041e86d401ea65bd6 (commit) from ada76432a60514720629d684da22c2fc98b81276 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 24090c3954b1de0e313318e041e86d401ea65bd6 Author: Rupert Swarbrick <rsw...@gm...> Date: Mon Jul 1 21:52:36 2013 +0100 Make some-bfloatp and some-floatp deal correctly with rat expressions. Fixes bug 2602. diff --git a/src/simp.lisp b/src/simp.lisp index 22f58c2..80d6cf8 100644 --- a/src/simp.lisp +++ b/src/simp.lisp @@ -205,17 +205,24 @@ (and (not (atom x)) (not (atom (car x))) (member (caar x) '(rat bigfloat))))) -;; is there a bfloat anywhere in x? -(defun some-bfloatp (x) - (or ($bfloatp x) +;; Does X or a subexpression match PREDICATE? +;; +;; If X is a tree then we recurse depth-first down its arguments. The specrep +;; check is because rat forms are built rather differently from normal Maxima +;; expressions so we need to unpack them for the recursion to work properly. +(defun subexpression-matches-p (predicate x) + (or (funcall predicate x) (and (consp x) - (some #'some-bfloatp (cdr x))))) + (if (specrepp x) + (subexpression-matches-p predicate (specdisrep x)) + (some (lambda (arg) (subexpression-matches-p predicate arg)) + (cdr x)))))) -;; is there a float anywhere in x? -(defun some-floatp (x) - (or (floatp x) - (and (consp x) - (some #'some-floatp (cdr x))))) +;; Is there a bfloat anywhere in X? +(defun some-bfloatp (x) (subexpression-matches-p '$bfloatp x)) + +;; Is there a float anywhere in X? +(defun some-floatp (x) (subexpression-matches-p 'floatp x)) ;; EVEN works for any arbitrary lisp object since it does an integer ;; check first. In other cases, you may want the Lisp EVENP function diff --git a/tests/rtest16.mac b/tests/rtest16.mac index 306c06f..62405d1 100644 --- a/tests/rtest16.mac +++ b/tests/rtest16.mac @@ -1853,4 +1853,6 @@ map(lambda([x], featurep(x, noninteger)),[0,1,2013]); block([domain : 'real], integrate(x^(8*%i-1),x)); -%i*x^(8*%i)/8$ - +/* #2602: some-bfloatp and some-floatp recursed wrongly on rat expressions */ +?some\-bfloatp(rat(1/2)); +false$ ----------------------------------------------------------------------- Summary of changes: src/simp.lisp | 25 ++++++++++++++++--------- tests/rtest16.mac | 4 +++- 2 files changed, 19 insertions(+), 10 deletions(-) hooks/post-receive -- Maxima CAS |