|
From: Eduardo O. <edu...@gm...> - 2025-10-11 06:01:50
|
Hi all,
I found a nice way to _try_ to understand the "result" arguments of
"dim-*" functions. These lines in displa.lisp define how objects like
"a^b" will be displayed:
(displa-def mexpt dimension-superscript)
(displa-def %mexpt dimension-superscript)
They set the "dimension" property of both "mexpt" and "%mexpt" to the
function "dimension-superscript". The code below replaces that by
"dimension-superscript-saving", that is a wrapper around
"dimension-superscript" that appends the "result" of
"dimension-superscript" to the list stored in the variable
"dim-saved", and after that it makes Maxima display some objects of
the form "a^b", and it prints the contents of "dim-saved"...
Here is the code - obviously a very fragile hack:
to_lisp();
(defvar dim-saved)
(setq dim-saved nil)
(defun dim-save (result)
(setq dim-saved `(,@dim-saved ,result))
result)
(defun dimension-superscript-saving (form result)
(dimension-superscript form (dim-save result)))
(displa-def mexpt dimension-superscript-saving)
(displa-def %mexpt dimension-superscript-saving)
(to-maxima)
b^cd;
ab^cd;
ab^cde;
ab^cde[fg];
ab^cde[fgh];
to_lisp();
(loop for o in dim-saved
do (format t "~a~%" o))
(to-maxima)
and here is the relevant part of its output, slightly reindented:
(%i2) b^cd;
cd
(%o2) b
(%i3) ab^cd;
cd
(%o3) ab
(%i4) ab^cde;
cde
(%o4) ab
(%i5) ab^cde[fg];
cde
fg
(%o5) ab
(%i6) ab^cde[fgh];
cde
fgh
(%o6) ab
(%i7) to_lisp();
Type (to-maxima) to restart, ($quit) to quit Maxima.
MAXIMA> (loop for o in dim-saved
do (format t "~a~%" o))
((32 0) b (0 1 d c))
((31 0) a b (0 1 d c))
((31 0) a b (0 1 e d c))
((30 0) a b (0 2 (0 -1 g f) (0 0 e d c)))
((29 0) a b (0 2 (0 -1 h g f) (0 0 e d c)))
Now the question. Each of these "result"s looks like the "dimension
strings" that are described in this comment in displa.lisp,
;; <dimension string> ::= () | (<string element> . <dimension string>)
;; <string element> ::= character |
;; (<column-relative> <row-relative> . <dimension string>) |
;; (<drawing function> . args)
;; <column-relative> ::= <fixnum>
;; <row-relative> ::= <fixnum>
;; <drawing function> ::= D-HBAR | D-VBAR | D-INTEGRALSIGN | ...
;; When a character appears in a dimension string, it is printed and
;; the cursor moves forward a single position. (The variable OLDCOL is
;; incremented) When a form with a fixnum car is encountered, the
;; first two elements of the form are taken to be relative displacements
;; for OLDCOL and OLDROW. *** NOTE *** After drawing the cddr of the form,
;; OLDROW is reset to its original value, but OLDCOL is left in the new
;; position. Why this is done is beyond me. It only appears to complicate
;; things.
but some parts of them are reversed in a funny way... for example, I
_guess_ that
((29 0) a b (0 2 (0 -1 h g f) (0 0 e d c)))
is converted to this
((29 0) a b (0 2 (0 -1 f g h) (0 0 c d e)))
in some part of displa.lisp - but I couldn't find the code that does
that, and I am not sure of the right way to reverse the parts.
Any hints?
Thanks in advance!
Eduardo =)
|