Date: Jun 22, 2004 9:21 PM
Author: Joe Riel
Subject: Re: Maple procedures

Carl Devore wrote:
> On 21 Jun 2004, John Creighton wrote:

>>Is there anyway way to read how maple procedures are programmed?
> In addition to Joe Riel's suggestion, sometimes showstat(procedure_name)
> gives more readable output than eval(procedure_name). And sometimes the
> eval(...) will be the more readable one.

A disadvantage of showstat, particularly if you want to cut and paste
the output, is that it includes line numbers. Here is a simple
procedure I threw together to remove the line numbers.

PrintProc := proc(p::name,lines::{posint,posint..posint})
local s,width;
option `Copyright (C) 2004 by Joseph S. Riel. All rights reserved.`;
description "Print like showstat, but without line numbers";
width := interface('screenwidth'=infinity);
s := sprintf("%s",debugopts('procdump'=
# This is a bit crude, but easier than counting the digits in
# the line numbers.
use StringTools in
s := RegSubs("\n [0-9] "="\n ",s);
s := RegSubs("\n [0-9][0-9] "="\n ",s);
s := RegSubs("\n [0-9][0-9][0-9] "="\n ",s);
s := RegSubs("\n[0-9][0-9][0-9][0-9] "="\n ",s);
# Decrease initial indentation to 2.
s := RegSubs("\n "="\n ",s);
end use;
catch "procedure name expected":
error "%1 is not a procedure name",p
finally interface('screenwidth'=width)
end try;

Joe Riel