Is there a convenient way to find out which DownValues
is used when calling a function? As an example, consider the following function:
abs[Complex[0,n_]] := Complex[0,Abs[n]]
abs[n_?NumberQ] := Sign[n] n
abs[n_?NumericQ] /; MemberQ[{-1,0,1}, Sign[n]] := Sign[n] n
abs[x_] /; Internal`SyntacticNegativeQ[x] := -x
abs[x_] := x
which is just some random code. Now, I want to know which DownValues
fired when I evaluate abs[N@I]
? Obviously, this example is simple enough that I can figure out which DownValues
would fire by inspection, assuming the DownValues
occur in the order listed above. However, suppose there are many more DownValues
, or suppose you don't to spend time perusing the DownValues
to figure out which one would fire for a particular input. Is there some simple function that will give me which DownValues
has fired?
Comments
Post a Comment