MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: list of Mma commands with specified properties

Begin forwarded message:

> Date: Wed, 5 Apr 1995 10:03:45 -0400 (EDT)
> From: Jack Goldberg <jackgold at>
> To: mathgroup at
> Subject: [mg644] list of Mma commands with specified properties

Hi Group;
	A student asked me "Which Mma commands have the option 

of allowing Trig->False so that she could set Trig->True?"
	This question raises a more general issue which I pose to 

you in the form of two questions:
	(1) How does one ask for a list of commands which have a
	    specified option such as Trig->False ?
(I won't clutter cyberspace with my makeshift solution, since I'll
bet there is a "professional" way to do it.)
	(2) Same question for attributes, say for instance, Listable?

Another student asked this question (actually it was me):
	(3) Is there a way of forcing the front end to produce  

	     output in MatrixForm in a given Mma session rather than
	    a list of lists (of equal length) as it does now?
This is of value when one knows in advanced that a particular 

session will be dealing entirely with matrices.

(1) & (2):  The main problem here is obtaining a list of the commands  
available in Mathematica in a form that Mathematica can use as input to  
other commands.  The "?*" produces a "list" of all objects currently  
defined, but the "?" command can't be composed with other commands, so one  
must be sneaky.  I used the following package (which I wrote myself  
several years ago) to capture the output from "?*" in a text file with  
page width 30:

-----------begin package------------	 



  LogToFile::usage = "LogToFile[filename, pagewidth, pageheight] toggles  
logging to the named file.  The variables 'pagewidth' and 'pageheight' are 

optional; if not specified, they will be set to 78 and 22 (i.e., the 

Mathematica defaults), respectively.  Logging to multiple files is  

the files may be toggled in arbitrary order."


  LogToFile[filename_, pagewidth_:78, pageheight_:22] :=

  ( tag = ToString[filename];

    If[MemberQ[$Echo, tag],

     (* True *)
      $Echo = Complement[$Echo, {tag}];
      $Output = Complement[$Output, {tag}];
      $Messages = Complement[$Messages, {tag}];
      $Urgent = Complement[$Urgent, {tag}];
      Close[tag]; ,

     (* False *)

      OpenAppend[tag, FormatType -> OutputForm,
                      PageWidth -> pagewidth,
                      PageHeight -> pageheight];
      PrependTo[$Echo, tag];
      PrependTo[$Output, tag];
      PrependTo[$Messages, tag];
      PrependTo[$Urgent, tag];
  End[ ]

EndPackage[ ]

--------------end package--------------

For some reason, Mathematica running on the NeXT won't open and read text  
files that it wrote itself using this package, so I used my text editor to  
copy the contents of the file the package created to another file named  
"Commands.txt".  Then, in a new Mathematica session:  


   commands = ReadList["Commands.txt", Word]


      MemberQ[Options[ToExpression[#]], Trig -> _]&]

It's clumsy, but it works.  And once you have the textfile, you can search  
it for any old option.

(3)  Try this, or some variant:

MyOutput[x_] := MatrixForm[x] /; MatrixQ[x];
MyOutput[x_] := x /; ! MatrixQ[x];

$Post = MyOutput

--Lou Talman
  Metropolitan State College of Denver

  • Prev by Date: Student version in high schools
  • Next by Date: Re: FactorInteger Print Formatting
  • Previous by thread: Re: list of Mma commands with specified properties
  • Next by thread: Re: Re: list of Mma commands with specified properties