From: Eduardo O. <edu...@gm...> - 2025-01-04 03:23:15
|
Hi list, I played with qm-maxima a bit - links: https://github.com/QMeqGR/qm-maxima https://github.com/QMeqGR/qm-maxima/blob/master/qm.lisp https://sourceforge.net/p/maxima/mailman/message/58827564/ and I saw that it displays kets in a nice way, like this: ket([a,b]); /* |a, b> */ The code that implements that is in qm.lisp. I found it hard to understand, and I tried to rewrite it. I got this: (setf (get 'ket 'dissym) '((#\|) . (#\>))) (setf (get '$ket 'dimension) 'dimension-ket) (defun dimension-ket (e so-far) (dimension-match `((ket) ,@(cdadr e)) so-far)) and when I was trying to understand `dimension-match' I stumbled on `displa-def', and I tested this, on a clean Maxima: (displa-def $ket dimension-match "|" ">") I got the impression that this is a high-level way to make ket([a,b]) be displayed as "|a, b>". Am I right? Or the code with two `setf's and a `defun' is better? Why? Now my main question. I've been using some objects - let me call them "ccc"s - that I would like to display in a special way, as: ccc(x,y,z); /* <x:y:z> */ This code almost does what I want: to_lisp(); (displa-def $ket dimension-match "|" ">") (displa-def $aaa dimension-nary ":") (displa-def $bbb dimension-match "<" ">") (to-maxima) ket(a,b); /* |a, b> */ ccc([args]) := bbb(apply('aaa, args))$ ccc(x,y,z); /* <x:y:z> */ but with this definition for ccc the internal representation of ccc(x,y,z) is: (($BBB SIMP) (($AAA SIMP) $X $Y $Z)) and my functions to manipulate "ccc"s would be easier to write if the internal representation of ccc(x,y,z) would be just this, (($CCC SIMP) $X $Y $Z) but for that the "displa"ying of "ccc"s needs to be more complex - it needs to add the ":"s as separators AND the "<" and the ">" at the extremities. How can I do that? Thanks in advance! =) Eduardo Ochs http://anggtwu.net/eev-maxima.html |