mgrep: a tool for searching Maple repositories

September 20 2009 Joe Riel 6446
Maple

3

A few years ago I wrote a tool, mgrep, for searching Maple repositories;  download mgrep.zip. The zip file includes the noweb source (mgrep.nw), however, it is missing some of the files needed to rebuild the documentation—I will add them later when I bring an old drive back online.  You should not, however, need to rebuild the documentation (mgrep.pdf) because it is included along with the shell-script (mgrep) and gawk file (mgrep.awk).  To use the tool you will need to install mgrep and mgrep.awk in a directory in your path.  The --help option prints a brief help page.

Here I use mgrep to partially explore a question that  acer poses, that, whether % may be usefully employed in a Maple procedure. A reasonable start is to see whether it is so used in the distributed Maple library.  First I go to the lib subdirectory of the Maple installation, then call mgrep to search maple.mla for all procedures that use % as a name

$ cd $MAPLE_ROOT/lib
$ mgrep --name % maple.mla
maple.mla:
fdiff
liesymm/difftools/convert/D1
convert/to_special_function/simplify
codegen/optimize/statseq/newname
codegen/optimize/count
procmake
procbody/toneutral

The --code (-c) option can be used to print the code. Here I'll use it to print the relevant portion of lieysmm/difftools/convert/D1:

$ mgrep -hca liesymm/difftools/convert/D1 maple.mla | sed /%/q
liesymm/difftools/convert/D1 := 
proc(F)
local t, t1, tot, f, g, h, x, vars, i, idx, y, p, gg;
option `Copyright (c) 1992 by J. S. Devitt. All rights reserved.`;
    subs('Diff' = 'diff', F);
    g := %;

I don't see the point of that usage, it seems as though the straightforward assignment g := subs('Diff' = 'diff', F) would work just as well.

The usage of % in the other procedures is of the form % || index, which generates %1, %2, etc.

Please Wait...