Subject: Re: [Maxima] puzzle with pattern matching
From: Richard Fateman
Date: Mon, 26 Aug 2002 16:03:09 -0700
;;a better version which does (I hope) just the right level of
evaluation of variables
(defun getdec (p e)
(let (x z)
(cond ((setq x (mget p 'matchdeclare))
(cond ((not (atom (car x))) (setq x (car x))))
(setq z (nconc (mapcar 'memqargs (cdr x)) (ncons e)))
(setq x (car x))
(cond ((not (atom x)) (setq x (car x))))
(setq z
(cond ((or (memq x '($true t $all))
(and (fboundp x) (not (get x 'translated))))
(cons x z))
(t ;(push (second z) *match-specials*)
`(is (list '(,x) ,@(mapcar #'(lambda (r) `(list '(mquote)
,r)) z)))))) ;;changed
(cond ((memq (car z) '($true t $all)) (list 'msetq p e))
(t (list 'cond
(list z (list 'msetq p e))
'((matcherr)))))))))