Ask for the syntax of representing operators in Common-Lisp
- Subject: Ask for the syntax of representing operators in Common-Lisp
- From: Barton Willis
- Date: Wed, 12 Jul 2006 06:09:27 -0500
The function 'common_lisp' might work OK for expressions
that involve trig-like functions and polynomials.
i1) load("tocl.lisp")$
(%i2) common_lisp((a*x^2+b*x+c)/(1+sin(x)))$
(LAMBDA (A B C X) (* (+ C (* B X) (* A (EXPT X 2))) (EXPT (+ 1 (SIN X))
-1)))
---start tocl.lisp-----------
(defun $common_lisp (e)
(let (($listconstvars nil))
(print `(lambda ,(sort (mapcar 'stripdollar (margs ($listofvars e)))
'string<) ,(tocl ($ratdisrep e))))
'$done))
(setf (get 'mplus 'cl-function) '+)
(setf (get 'mtimes 'cl-function) '*)
(setf (get 'mexpt 'cl-function) 'expt)
(defun tocl (e)
(if ($mapatom e) (stripdollar e)
`(,(or (get (mop e) 'cl-function) (stripdollar (mop e))) ,@(mapcar
'tocl (margs e)))))
--- end of file----
Barton