Group Abstract Group Abstract

Message Boards Message Boards

How to list the supported functions on a variable?

Posted 4 years ago

Hi, How to find what methods are supported on a variable. In the following code "trainingData" is a variable that holds 60K image and its numeric value in the image.

trainingData = ResourceData["MNIST", "TrainingData"]

If I want to browse the images how to do it. I guessed this might behave as list(https://www.wolfram.com/language/fast-introduction-for-programmers/en/lists/) and tried

trainingData[[5]]

which worked. But how to do this more systematically without guessing. Since in Mathematica everything is a symbol, is there a way to list all functions supported on a variable?

PS: I am new to Mathematica. I have intermediate experience in Matlab and Python. What I am looking for is similar to the "methods" function in Matlab or "dir" function in Python. Thanks

POSTED BY: Bob Rick
4 Replies
Posted 4 years ago

Does the "Rule" function actually supports list syntax. ie. using "[ ]"

Don't think about it as "list syntax". The double square brackets, [[]], is just syntactic sugar. It's just a convenient alternative to Part. Part is just a normal "function" that can be applied to any expression.

Rohit showed you how to inline the selection function. The Last function that it uses is very common. Other useful "destructuring" functions are Head, First, Most, Rest, and Part. Part has some interesting features, including things similar to Python's slice function.

When filtering/searching lists, Select, Cases, and Position are frequently used. Reorganizing lists can be done with GroupBy and GatherBy.

That's just the tip of the iceberg.

POSTED BY: Eric Rimbey
Posted 4 years ago
POSTED BY: Rohit Namjoshi
Posted 4 years ago
POSTED BY: Bob Rick
Posted 4 years ago
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