Ask for the syntax of representing operators in Common-Lisp



Try this, which changes x/y  to   (/ x y)  instead of  (* x (expt y -1)).
The trick is to use nformat.


(defun $common_lisp (e)
  (let (($listconstvars nil))
    (print `(lambda ,(sort (mapcar 'stripdollar (margs ($listofvars e)))
    'string<) ,(tocl (nformat($ratdisrep e)))))
    '$done))

(setf (get 'mplus 'cl-function) '+)
(setf (get 'mtimes 'cl-function) '*)
(setf (get 'mexpt 'cl-function) 'expt)
(setf (get 'mquotient 'cl-function) '/)

(defun mapatom-to-cl (e)
  (cond ((eq e '$%i) (complex 0 1))
	(($ratnump e) `(/ ,($num e) ,($denom e))) 
	((eq e '$%pi) pi) 
	(($constantp e) ($float e)) ;; converts big floats to doubles
	(t (stripdollar e))))

(defun tocl (e)
  (if ($mapatom e) (mapatom-to-cl e)
    `(,(or (get (mop e) 'cl-function) (stripdollar (mop e))) ,@(mapcar
    'tocl (margs e)))))