|
From: Eduardo O. <edu...@gm...> - 2025-10-21 18:13:19
|
Update! This is much better - the change is the ",@result" in the
backquote:
to_lisp();
(setf (get '$abcdef 'dimension) 'dim-abcdef)
(defun dim-abcdef (form result)
(declare (ignorable form result))
(setq depth 2)
(setq maxdp 2)
(setq width 3)
`((-3 -2 #\f #\e) (-1 -1 #\d #\c #\b) #\a ,@result))
(to-maxima)
linel : 40;
display2d_unicode : false;
matrix([abcdef(), 42]);
42 + abcdef();
abcdef();
The output is:
(%i4) matrix([abcdef(), 42]);
[ a 42 ]
(%o4) [ bcd ]
[ ef ]
(%i5) 42 + abcdef();
(%o5) a + 42
bcd
ef
(%i6) abcdef();
(%o6) a
bcd
ef
It works well enough for what I need, but it is drawn glued to the "+"
instead of separated from it by a space. Any suggestions very welcome,
of course - but I'll try to clean up the code even without that fix,
and I will post it here when it gets ready...
Cheers =),
Eduardo
On Tue, 21 Oct 2025 at 11:52, Eduardo Ochs <edu...@gm...> wrote:
> Hi list!
>
> First, some context. In this message from a few days ago
>
> https://sourceforge.net/p/maxima/mailman/message/59245670/
>
> Robert Dodier showed a way to draw matrixes without border characters.
> I have lots of objects - like trees and certain diagrams for teaching
> set comprehensions - that can be represented nicely in ascii art, and
> using RD's trick I can almost do what I want/need.
>
> The most obvious way of handling that problem is saying that what I
> want is wrong, but let me follow another path, and start by a minimal
> example. Here is what I can do with RD's trick. If we run this in a
> REPL in a recent Maxima,
>
> to_lisp();
> (setf (get '$barematrix 'dimension) 'dim-$barematrix)
> (defun dim-$barematrix (form result)
> (let (($display_matrix_brackets nil))
> (dim-$matrix form result)))
> (to-maxima)
> linel : 60;
> display2d_unicode : false;
> BM : barematrix(["a "], ["bcd"], ["ef "]);
> matrix([BM, 42]);
>
> We get this:
>
> (%i4) BM : barematrix(["a "], ["bcd"], ["ef "]);
> a
>
> (%o4) bcd
>
> ef
> (%i5) matrix([BM, 42]);
> [ a ]
> [ ]
> (%o5) [ bcd 42 ]
> [ ]
> [ ef ]
> (%i6)
>
> BM looks like "a\n\nbcd\n\nef", but I would like to get something that
> looks like "a\nbcd\nef", without the interline spacings.
>
> Here is an attempt to get a "a\nbcd\nef" using very low-level tools.
> If we run this in a Maxima REPL,
>
> to_lisp();
> (setf (get '$abcdef 'dimension) 'dim-abcdef)
> (defun dim-abcdef (form result)
> (declare (ignorable form result))
> (setq depth 2)
> (setq maxdp 2)
> (setq width 3)
> '((-3 -2 #\f #\e) (-1 -1 #\d #\c #\b) #\a))
> (to-maxima)
> linel : 40;
> display2d_unicode : false;
> matrix([abcdef(), 42]);
> 42 + abcdef();
> abcdef();
>
> it works, or sort of, in some contexts, but it is very buggy. Look:
>
> (%i4) matrix([abcdef(), 42]);
> [ a 42 ]
> (%o4) [ bcd ]
> [ ef ]
>
> (%i5) 42 + abcdef();
> a + 42
> bcd
> ef
> (%i6) abcdef();
> 24 +
>
> ef
>
> I'm looking for suggestions on what to fix in my dim-abcdef. If anyone
> wants to take a look at the tools that I am using to explore
> displa.lisp and displm.lisp, they are here -
> <http://anggtwu.net/MAXIMA/2025-testdispla.lisp.html> - but they are
> not worth looking at now, and they are only "documented" using test
> blocks: <http://anggtwu.net/eepitch.html#test-blocks>.
>
> Suggestions like "trace the variables such and such" would be great,
> and suggestions like "use the functions blah and blah instead of your
> setqs", or "make your function return bleh instead of '((-3 -2 #\f
> #\e) (-1 -1 #\d #\c #\b) #\a)" would be even better...
>
> Thanks in advance!
> Eduardo Ochs =)
> http://anggtwu.net/eev-maxima.html
>
>
|