Message Boards Message Boards

0
|
1145 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to list all functions available in Wolfram?

Posted 7 months ago

Hello! I use

EntityValue[WolframLanguageData[], {"Name", "PlaintextUsage"}, 
            "EntityPropertyAssociation"];

to list the functions and other symbols available in Wolfram, to make them callable from Clojure. (Thank you, Rohit!) I would like to learn how to distinguish functions from non-functions (I assume there is some property I could request in addition to Name and PlaintextUsage that would tell me this.) Also, is there some way to modify this code to give me only functions, or only non-functions?

Perhaps something from Find All Defined Functions could be used, but I am not sure how to put it all together.

Thank you for any tips!

POSTED BY: Jakub Holý
2 Replies
Posted 6 months ago

Thank you very much, Eric! I am fogetting how unique Wolfram is. I took now a different approach.

POSTED BY: Jakub Holý
Posted 7 months ago

First off, there are thousands of symbols, so it doesn't seem practical to be inspecting them directly.

Second, many built-in symbols are ReadProtected, so you can't really inspect them very closely. Even symbols that aren't ReadProtected might still hide their implementation details.

Third, some symbols don't have any definitions--they're more like reserved symbols. E.g. \[FormalA]. And some others are interpreted differently in different situations. E.g. Automatic.

If you're not actually wanting to inspect all built-in symbols, but instead want "to learn how to distinguish functions from non-functions", then you need to be clear about what you mean by "function". To the Wolfram Language, everything is an expression, and the Wolfram Language has a process for evaluating expressions that involves replacement rules. The concept of function is a mathematical one--the Wolfram Language can only give you some tools for modeling functions in code.

Here are two different ways you could model a function in WL:

(* Set/SetDelayed *)
(* This adds an element to DownValues *)
somefunc[x_, y_] := x + 3 y;

(* Function *)
(* This adds an elemnt to OwnValues, but that element is an expression 
   that will be applied to arguments when it appears as the head of an expression*)
otherfunc = Function[{x, y}, x + 3 y];

Are these both functions to you? It's hard to find a property that will select these correctly. You can't just say "if it has down-values then it's a function".

DownValues[somefunc]
(* {HoldPattern[somefunc[x_, y_]] :> x + 3 y} *)

DownValues[otherfunc]
(* {} *)

OwnValues[somefunc]
(* {} *)

OwnValues[otherfunc]
(* {HoldPattern[otherfunc] :> Function[{x, y}, x + 3 y]} *)

So, your question doesn't really seem to be well-specified. What is it that you're actually wanting to do or learn? Do you actually need a rigorous way to distinguish function from non-function, or is there some other way to achieve your objective?

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract