Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Suppressing evaluation in a proc

0 views
Skip to first unread message

Rouben Rostamian

unread,
Nov 24, 2009, 5:27:14 PM11/24/09
to
I am having a problem with suppressing evaluation within a proc.
I hope that someone can help me here. Consider the following:

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

Nasser M. Abbasi

unread,
Nov 24, 2009, 5:56:30 PM11/24/09
to

"Rouben Rostamian" <r...@nohost.noname> wrote in message
news:hehmk2$t13$1...@news.albasani.net...


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


Rouben Rostamian

unread,
Nov 24, 2009, 6:23:36 PM11/24/09
to
On 2009-11-24, Nasser M. Abbasi <n...@12000.org> wrote:
>
> "Rouben Rostamian" <r...@nohost.noname> wrote in message
> news:hehmk2$t13$1...@news.albasani.net...
>>I am having a problem with suppressing evaluation within a proc.
>> I hope that someone can help me here. Consider the following:
>>
>> 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.
>
> this below works on my Maple 12 system
>
>> restart;
>> doit := proc(x)
>> plots[textplot]([1, 1, typeset(`x[1]/x[2]`)]);
>> end proc;

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

Nasser M. Abbasi

unread,
Nov 24, 2009, 8:06:43 PM11/24/09
to

"Rouben Rostamian" <r...@nohost.noname> wrote in message
news:hehpto$1qj$1...@news.albasani.net...

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


Rouben Rostamian

unread,
Nov 24, 2009, 9:18:04 PM11/24/09
to
On 2009-11-25, Nasser M. Abbasi <n...@12000.org> wrote:
>
> 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

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

Robert Israel

unread,
Nov 25, 2009, 2:38:25 AM11/25/09
to
Rouben Rostamian <r...@nohost.noname> writes:

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

Rouben Rostamian

unread,
Nov 25, 2009, 10:52:04 AM11/25/09
to
On 2009-11-25, Robert Israel <isr...@math.MyUniversitysInitials.ca> wrote:
>
> 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;

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

Robert Israel

unread,
Nov 25, 2009, 4:03:16 PM11/25/09
to
Rouben Rostamian <r...@nohost.noname> writes:

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

Rouben Rostamian

unread,
Nov 26, 2009, 12:05:55 AM11/26/09
to
On 2009-11-25, Robert Israel <isr...@math.MyUniversitysInitials.ca> wrote:
> Rouben Rostamian <r...@nohost.noname> writes:
>>
>> 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?
>
> 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

0 new messages