restart;
x := [2,3];
plots[textplot]([1, 1, typeset('x'[1]/'x'[2])]);
This produces the result that I want -- the quotation marks
suppress the evaluation of x and typeset() produces what
one would write as \frac{x_1}{x_2} in the TeX notation.
However if the typeset() command is embedded within a proc(), as in:
restart;
doit := proc(x)
plots[textplot]([1, 1, typeset('x'[1]/'x'[2])]);
end proc;
doit([2,3]);
then the quotation marks do not suppress evaluation and the
result is \frac{2}{3}. Is there a way to tell Maple not
to evaluate x here?
I am doing this on Maple 13.02.
--
Rouben Rostamian
hi;
this below works on my Maple 12 system
restart;
> doit := proc(x)
> plots[textplot]([1, 1, typeset(`x[1]/x[2]`)]);
> end proc;
--Nasser
That produces a literal "x[1]/x[2]" while I want a typeset
fraction like TeX's \frac{x_1}{x_2}. As noted above, the
interactive command
plots[textplot]([1, 1, typeset('x'[1]/'x'[2])]);
does exactly that. The problem is that it stops working
if it is called from within a proc.
--
Rouben Rostamian
Well, they look exactly the same to me (i.e. your original non-proc() way
and my way) when I run them on classical interface (which is what I always
use) on Maple.
Here is a screen shot of my monitor:
http://12000.org/tmp/maple_fraction/p.JPG
I do not know why the way you had it does not work inside a proc(). May be
if you ask in Maple primes, there are Maple experts there who would know for
sure.
good luck,
--Nasser
Oh, I see. I don't use the classical worksheet so I hadn't
tested it there. Thanks for the screenshot.
> I do not know why the way you had it does not work inside a proc().
> May be if you ask in Maple primes, there are Maple experts there who
> would know for sure.
I have worked my way around the issue so it's not
critical right now. I may go over at Maple
Primes if it comes up again.
Thanks for your input,
Rouben Rostamian
The problem is that your procedure has x as its formal parameter.
All occurrences of the formal parameter x in the body of the procedure
will be replaced by the actual parameter, in this case [2,3], when the
procedure is called. Unevaluation quotes don't prevent that. You could
try this, which uses the global variable x rather than the formal parameter.
Here the unevaluation quotes should work, even if x has been assigned a value.
> doit := proc(x)
plots[textplot]([1, 1, typeset(':-x[1]/:-x[2]')]);
end proc;
.
--
Robert Israel isr...@math.MyUniversitysInitials.ca
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia Vancouver, BC, Canada
Thank you, Robert. This is exactly what I wanted.
The use of :- in this context is new to me. I know about
its use in the context of modules, but this looks different.
I tried ?:- to learn more about it but it lead to the documentation
of "use" which does not seem to be directly related.
Is there a good place in the documentation to learn more about
the details of the :- construct?
--
Rouben Rostamian
For any name x, :-x is the global variable x, as distinct from
local variables, formal parameters, module exports etc. See the
help page ?colondash
That was very helpful. Thanks again.
--
Rouben Rostamian