Tim, Waldek,

This patch is a band-aid for the hex(10) bug.
I think there are some deeper inconsistencies however.
Consider the following:

(17) -> radix(5/24,39)
                    ____
   (17)  0 . 8 4 34
                                                      Type: RadixExpansion 39
(18) -> radix(5/24,40)
                     _
   (18)  0 . 8 D
                                                      Type: RadixExpansion 40

why do we get letters in (18) but all digits in (17)?

(21) -> radix(5/24,43)
                 ____
   (21)  0 . 8 41
                                                      Type: RadixExpansion 43

Here we get a ragit greater than 36 but

(22) -> radix(35,36)

   (22)  Z
                                                      Type: RadixExpansion 36
(23) -> radix(36,37)

   >> Error detected within library code:
   index out of range

(23) -> )set output tex on
(23) -> radix(10,16)

   (23)  A
$$
#\A
\leqno(23)
$$

TeX shows #\A

(25) -> )set output tex off
(25) -> radix(10,16)

   (25)  A
                                                      Type: RadixExpansion 16
(26) -> exprex(%)

   (26)  "{#\A}"

exprex shows the preconditioned output form which shows #\A

Arthur





--- mathml.spad.pamphlet	2007-12-11 07:00:45.000000000 -0800
+++ mathml.spad.pamphlet.new	2007-12-15 20:31:05.000000000 -0800
@@ -25,14 +25,14 @@
 At this time (2007-02-11) the package only has a presentation
 package.  A content package is in the
 works however it is more difficult.  Unfortunately Axiom does
-not make its semantics easliy available.  The \spadtype{OutputForm}
+not make its semantics easily available.  The \spadtype{OutputForm}
 domain mediates between the individual Axiom domains and the
 user visible output but \spadtype{OutputForm} does not provide full
 semantic information.  From my currently incomplete understanding
 of Axiom it appears that remedying this would entail going back
 to the individual domains and rewriting a lot of code.
 However some semantics are conveyed directly by \spadtype{OutputForm} and other
-things can be deduced from \spadtype{OutputForm} or form the original
+things can be deduced from \spadtype{OutputForm} or from the original
 user command.
 
 \section{Displaying MathML}
@@ -107,7 +107,7 @@
 I don't know of any Axiom command that produces such an object. In
 fact at present I see the case of "SUPERSUB" being used for putting
 primes in the superscript position to denote ordinary differentiation.
-I also only see the "SUB" case being only used to denote partial
+I also only see the "SUB" case being used to denote partial
 derivatives.
 
 \section{)set output mathml on}
@@ -116,7 +116,7 @@
 Making mathml appear as output during a normal Axiom session
 by invoking ")set output mathml on" proved to be a bit tedious
 and seems to be undocumented.  I document my experience here
-in case in proves useful to somebody else trying to get a new
+in case it proves useful to somebody else trying to get a new
 output format from Axiom.
 
 In \spadtype{MathMLFormat} the functions 
@@ -231,7 +231,7 @@
 
 I don't see that this file is used anywhere but I made
 the appropriate changes anyway by searching for "TEX" and
-mimicing everthing for MMLFORM.
+mimicing everything for MMLFORM.
 
 \subsection{File src/doc/axiom.bib.pamphlet}
 
@@ -285,14 +285,14 @@
 The publicly exposed functions are:
 
     \spadfun{coerce: E -$>$ S}  This function is the main one for converting
-and expression in domain OutputForm into a MathML string.
+an expression in domain OutputForm into a MathML string.
 
     \spadfun{coerceS: E -$>$ S}  This function is for use from the command line.
 It converts an OutputForm expression into a MathML string and does
 some formatting so that the output is not one long line.  If you take
 the output from this function, stick it in an emacs buffer in
 nxml-mode and then indent according to mode, you'll get something that's
-nicer to look at than comes from coerce. Note that coerceS returns
+nicer to look at than what comes from coerce. Note that coerceS returns
 the same value as coerce but invokes a display function as well so that
 the result will be printed twice in different formats.  The need for this
 is that the output from coerce is automatically formatted with line breaks
@@ -377,7 +377,7 @@
     import List OutputForm
     import List String
 
-    -- local variables declarations and definitions
+    -- local variable declarations and definitions
 
     expr: E
     prec,opPrec: I
@@ -1191,15 +1191,31 @@
       null args => ""
       p : I := position(op,naryOps)
       p < 1 => error "unknown nary op"
-      -- need to test for "ZAG" case and divert it here, here's an
-      -- example including "op", the args list would be the rest of this
+      -- need to test for "ZAG" case and divert it here
+      -- ex 1. continuedFraction(314159/100000)
       -- {{+}{3}{{ZAG}{1}{7}}{{ZAG}{1}{15}}{{ZAG}{1}{1}}{{ZAG}{1}{25}}
       -- {{ZAG}{1}{1}}{{ZAG}{1}{7}}{{ZAG}{1}{4}}}
-      -- The first arg, the "3" in this case, could be a "ZAG" or something
+      -- this is the preconditioned output form
+      -- including "op", the args list would be the rest of this
+      -- i.e op = '+' and args = {{3}{{ZAG}{1}{7}}{{ZAG}{1}{15}}
+      -- {{ZAG}{1}{1}}{{ZAG}{1}{25}}{{ZAG}{1}{1}}{{ZAG}{1}{7}}{{ZAG}{1}{4}}}
+      -- ex 2. continuedFraction(14159/100000)
+      -- this one doesn't have the leading integer
+      -- {{+}{{ZAG}{1}{7}}{{ZAG}{1}{15}}{{ZAG}{1}{1}}{{ZAG}{1}{25}}
+      -- {{ZAG}{1}{1}}{{ZAG}{1}{7}}{{ZAG}{1}{4}}}
+      --
+      -- ex 3. continuedFraction(3,repeating [1], repeating [3,6])
+      -- {{+}{3}{{ZAG}{1}{3}}{{ZAG}{1}{6}}{{ZAG}{1}{3}}{{ZAG}{1}{6}}
+      -- {{ZAG}{1}{3}}{{ZAG}{1}{6}}{{ZAG}{1}{3}}{{ZAG}{1}{6}}
+      -- {{ZAG}{1}{3}}{{ZAG}{1}{6}}{...}}
+      -- In each of these examples the args list consists of the terms
+      -- following the '+' op
+      -- so the first arg could be a "ZAG" or something
       -- else, but the second arg looks like it has to be "ZAG", so maybe
-      -- test for #args > 1 and args.2 is "ZAG".
-      -- This test should work so long as axiom doesn't try to evaluate
-      -- the second half of the "and" when the first half is false.
+      -- test for #args > 1 and args.2 contains "ZAG".
+      -- Note that since the resulting MathML <mfrac>s are nested we need
+      -- to handle the whole continued fraction at once, i.e. we can't
+      -- just look for, e.g., {{ZAG}{1}{6}}
       (#args > 1) and (position("ZAG",stringify first rest args,1) > 0) =>
 	   tmpS : S := stringify first args
 	   position("ZAG",tmpS,1) > 0 => formatZag(args)
@@ -1224,11 +1240,17 @@
       s
 
     formatZag(args : L E) : S ==
-    -- {{ZAG}{1}{7}}
+    -- args will be a list of things like this {{ZAG}{1}{7}}, the ZAG
+    -- must be there, the '1' and '7' could conceivably be more complex
+    -- expressions
       tmpZag : L E := first args pretend L E
+      -- may want to test that tmpZag contains 'ZAG'
       #args > 1 => "<mfrac>"formatMml(first rest tmpZag,minPrec)"<mrow><mn>"formatMml(first rest rest tmpZag,minPrec)"</mn><mo>+</mo>"formatZag(rest args)"</mrow></mfrac>"
-      "<mfrac>"formatMml(first rest tmpZag,minPrec)formatMml(first rest rest tmpZag,minPrec)"</mfrac>"
-      
+      (first args = "..."::E)@Boolean => "<mo>&#x2026;</mo>"
+      position("ZAG",stringify first args,1) > 0 =>
+          "<mfrac>"formatMml(first rest tmpZag,minPrec)formatMml(first rest rest tmpZag,minPrec)"</mfrac>"      
+      "<mtext>formatZag: Unexpected kind of ZAG</mtext>"
+
     formatZag1(args : L E) : S ==
     -- make alternative ZAG format without diminishing fonts, maybe
     -- use a table
@@ -1285,6 +1307,10 @@
 	  -- where it arises.  Removed 2007-02-14
           concat(concat("<mtext>",str),"</mtext>")
 	-- if we get to here does that mean it's a variable?
+	-- test for something like #\A and strip off #\
+	str.1 = char "#" and str.2 = char "\" =>
+	    u : US := segment(3,len)$US
+	    concat ["<mi>",str.u,"</mi>"]
         concat ["<mi>",str,"</mi>"]
       l : L E := (expr pretend L E)
       null l => blank
_______________________________________________
Axiom-developer mailing list
Axiom-developer@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to