Output a list of keywords

Output a list of keywords

Post by Thomas Gui » Fri, 16 Dec 2005 20:07:38


Hi there

Does anybody know of a way to output a list of all reserved keywords in
Mathematica (such as the listing in Section A.10 of the Mathematica book)?

Thanks,
Thomas

--
Thomas Guignard
Laboratory of Electromagnetics and Acoustics
Swiss Federal Institute of Technology, Lausanne
 
 
 

Output a list of keywords

Post by Jean-Marc » Fri, 16 Dec 2005 21:17:04


Hi Thomas,

You could try some combinations of the function *Information* (short cut
"?") and wild cards such as in the following lines:

In[1]:=
?*

In[2]:=
?*`*

In[3]:=
?*`*`*

In[4]:=
?*`*`*`*

Best regards,
/J.M.

 
 
 

Output a list of keywords

Post by Bob Hanlo » Sun, 18 Dec 2005 04:26:13

FactorInteger[n=Length[nom=Names["System`*"]]]

{{2, 6}, {31, 1}}

Thread[Partition[nom,n/4]]


Bob Hanlon
 
 
 

Output a list of keywords

Post by Dr. Wolfga » Sun, 18 Dec 2005 18:25:33

Interesting question. May I add a specific question which fits the
topic: how do I get a list of the keywords used *directly* in my
specific notebook?

E.g. for the notebook containing only the following line

myFunction[x_]:=Sin[x]

the list should read

myFunction
Sin

This sometimes arises when I need to transform programs from one version
to the other and need to replace unknown functions.

Thanks in advance.

Regards,
Wolfgang
 
 
 

Output a list of keywords

Post by Bob Hanlo » Tue, 20 Dec 2005 21:10:12

This is close to what you asked for.

myFunction[x_]:=Sin[x]

(* The following should be the last cell in the notebook *)
Module[{
noms=Select[Names["*`*"],StringFreeQ[#, "`"]&]},
Union[Cases[Drop[
NotebookGet[EvaluationNotebook[ ]][[1]],-1],
_?(MemberQ[noms, #]&),Infinity]]]

{Input,myFunction,Sin,x}


Bob Hanlon

version

book)?
 
 
 

Output a list of keywords

Post by Dr. Wolfga » Wed, 21 Dec 2005 18:27:21

Thank you, Bob.

With the slight modification replacing
{noms = Select[Names["*`*"],StringFreeQ[#, "`"]&]}
by
{noms = Select[Names["*`*"], StringPosition[#, "`"] == {} &]}
your Module works also for Version 4.

Wolfgang