Re: functions that take a specified option
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg783] Re: functions that take a specified option
- From: Lou Talman <me at talmanl.mscd.edu>
- Date: Wed, 19 Apr 1995 00:27:50 -0400
The "Names" operator (whose existence had escaped me until I saw Dan
Wagner's posting) obviates the need for a package to solve the problem of
locating commands that admit certain options or that have certain
attributes. I had thought of a package because the only way I knew to get
my hands on what "Names" provides was so clumsy that I wanted to embed the
result in the package. The following does very nicely:
CurrentDefinitionList := Names[];
CommandList := Select[CurrentDefinitionList,
(!StringMatchQ[#, "$*"])&];
FindOption[name_] := Block[{dummy},Select[CommandList,
(dummy = ToExpression[#];
MemberQ[Options[dummy], name -> _]
|| MemberQ[Options[dummy], name :> _])&]];
FindAttribute[name_] :=
Select[CurrentDefinitionList,
MemberQ[Attributes[#], name]&];