From: Eduardo O. <edu...@gm...> - 2025-01-04 08:11:32
|
On Sat, 4 Jan 2025 at 04:35, Robert Dodier <rob...@gm...> wrote: > > Eduardo, try this. > > (displa-def $aaa dimension-nary ":") > (displa-def $bbb dimension-match "<" ">") > > (defun reform-ccc (form) > (list '($bbb) (cons '($aaa) (rest form)))) > > (defun dimension-ccc (form result) > (let* > ((reformed (reform-ccc form)) > (helper (get (caar reformed) 'dimension))) > (funcall helper reformed result))) > > (setf (get '$ccc 'dimension) 'dimension-ccc) > > Put that in a file, let's say "displa-ccc.lisp", and then say > load("displa-ccc.lisp") in your Maxima session. When I try that, I > get: > > (%i1) load ("displa-ccc.lisp"); > (%o1) displa-ccc.lisp > (%i2) ccc(a,b,c); > (%o2) <a:b:c> > (%i3) ccc(1,2,3,4); > (%o3) <1:2:3:4> > > The main idea is to rework the ccc expression to be bbb(aaa(...)) > within the display function for ccc, and display that using display > properties defined for aaa and bbb. Beautiful!!! =) Here is a version of your idea that people can test in a Maxima REPL: to_lisp(); (displa-def $aaa dimension-nary ":") (displa-def $bbb dimension-match "<" ">") (setf (get '$ccc 'dimension) 'dimension-ccc) (defun dimension-ccc (form result) (let* ((form2 `(($bbb) (($aaa) ,@(cdr form)))) (form2-dimension (get (caar form2) 'dimension))) (funcall form2-dimension form2 result))) (to-maxima) aaa(x,y,z); /* x:y:z */ bbb(aaa(x,y,z)); /* <x:y:z> */ ccc(x,y,z); /* <x:y:z> */ Many thanks! =) Eduardo |