1

How do you see the code form of a command in Mathematica?

I know there is a command in Mathematica, "Unprotect[]", but how do you actually use this?

  • Do notice many of the built-in functions are just blackboxes, but definitions of functions that are not blackboxes can be checked with the tools above, particularly the PrintDefinitions. – xzczd Jul 10 '20 at 04:13

1 Answers1

3

Unprotect[] is there to remove the Protected attribute. This allows the definition of a command to be modified, but doesn't necessarily allow you to see the code that makes up the unmodified command. Protect helps to prevent accidental changes like +=3 redefining the + command. You can even Protect your own functions if you're worried about accidentally changing a definition.

If you want to read the Wolfram code, I have used:

Needs["GeneralUtilities`"]
PrintDefinitions[Charting`ScaledTicks]

to access some of the definitions. However, Mathematica is proprietary software. There are many functions where this won't work. For example, PrintDefinitions[NDSolve] shows a few options, but the actual code itself is a kernel function that cannot be read in this way. If you really want to read the code itself for any arbitrary function, I suspect the only way is to apply for a position at WRI.

MassDefect
  • 10,081
  • 20
  • 30