Re: [Maxima] puzzle with pattern matching



Hi Zeng
your mail is much useful  for me.
yes this happen when pattern matching with a subscript construction from batch file.
So I write functions for cleaning the additional informations.
function distclean() is to search values list, if the element is array
from file then cleaning additional information.

(C2) batch("matchmake.mac");

batching #p/home/furuya/matchmake.mac
(C3) 			  DECLARE(myfeature, FEATURE)
(C4) 			    DECLARE(she, myfeature)
(C5) 		   myfeatureP(x) := FEATUREP(x, 'myfeature)
(C6) 	        MATCHDECLARE([matchme, matchmetoo], myfeatureP)
(C7) 		      DEFRULE(mymatch, matchme, matchme)
(C8) 		 DEFRULE(mymatch2, matchme	    , matchme)
					  matchmetoo
(C9) 			        heralias : she
(C10) 			      heralias2 : she
					     she
(C11) test1.mac$
(C12) ponpon(heralias2);
(D12)((|$she| SIMP ARRAY (0 "matchmake.mac" SRC)) |$she|) 
(C13) distclean();
(D13) DONE
(C14) ponpon(heralias2);
 ((|$she| SIMP ARRAY) |$she|) 
(D14) 				    she
				       she
(C15) mymatch2(heralias2);
(D15) 				      she
that's OK 
Gosei Furuya (go_furuya@infoseek.jp)
test1.mac
--------------------------------------------------------------------------
load("cleaner.lisp")$
 distclean():= for _i in values do  _i:cleaner(ev(_i)) $
---------------------------------------------------------------------------
cleaner.lisp
;;; -*-  Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
(in-package "MAXIMA")

(defun $cleaner (form)
  (cond ((consp form) 
	 (rplaca form (car (cleaner form)))
	 (rplacd form (cdr (cleaner form))))
	(t form)))
  
(defun cleaner (form)
  (let ((arrayflg 0))
  (labels ((rec (tree acc)
		(cond ((null tree) (nreverse acc))
		      ((consp (car tree))
		       (cond ((eql arrayflg 1)
			      (setf arrayflg 0)
			      (rec (cdr tree) acc))
			     (t 
			      (rec (cdr tree)
				   (cons (rec (car tree) nil) acc)))))
		      (t (rec (cdr tree)
			      (cond  ((equal 'ARRAY (car tree)) 
				      (setf arrayflg 1)
				      (cons (car tree) acc))
				     (t (cons (car tree) acc))))))))
    (rec form nil))))
	   
     
(defmfun $ponpon (form)
  (print form))
--------------------------------------------------------------------------------



> Hi, I noticed the following puzzling behavior when I do pattern matching
> of a subscript construction and variables read from batch file.
> Since I am new to maxima I am not sure if this is a bug or something
> (un)documented in the Byzantine manual.  It looks to me like the additional
> information inserted during batch loading for source level debugging is
> interfering with the pattern matcher:
> 
> (C106) batch ("matchmake.mac");
> 
> batching /tmp/matchmake.mac
> (C107)                    DECLARE(myfeature, FEATURE)
> (C108)                      DECLARE(she, myfeature)
> (C109)             myfeatureP(x) := FEATUREP(x, 'myfeature)
> (C110)          MATCHDECLARE([matchme, matchmetoo], myfeatureP)
> (C111)                DEFRULE(mymatch, matchme, matchme)
> (C112)           DEFRULE(mymatch2, matchme[matchmetoo], matchme)
> (C113)                          heralias : she
> (C114)                        heralias2 : she[she]
> (C115) mymatch (heralias);
> (D115)                                she
> (C116) mymatch2 (heralias2);
> 
> *** - GET: 0 is not a symbol
> 1. Break [15]> :q
> (C117) heralias2;
> (D117)                              she
>                                        she
> (C118) mymatch2 (she[she]);
> (D118)                                she
> (C119) heralias2_alt : she[she];
> (D119)                              she
>                                        she
> (C120) mymatch2 (heralias2_alt);
> (D120)                                she
> *** - Ctrl-C: User break
> 1. Break [50]> |$heralias|
> |$she|
> 1. Break [50]> |$heralias2|
> ((|$she| SIMP ARRAY (0 "matchmake.mac" SRC)) |$she|)
> 1. Break [50]> |$heralias2_alt|
> ((|$she| SIMP ARRAY) |$she|)
> 1. Break [50]>
> 
> Zheng