Tag Info

New answers tagged

4

The argument pattern can be read directly from the CompiledFunction expression as DaveStrider commented: cf = Compile[{{x, _Real}, {y, _Integer}}, Round[x/y]]; cf[[2]] {_Real, _Integer} The result information is printed by the CompiledFunctionTools package command CompilePrint: Needs["CompiledFunctionTools`"] CompilePrint[cf] 2 arguments ...


9

If your definitions are exactly like you show, every time, you can use belisarius's method, slightly refined: g[x_Integer] := x + 1 g[s_String] := s <> "!!!" (DownValues@g)[[All, 1, 1, 1, 2, 1]] {Integer, String} However this is fragile in that it will fail if your definitions are different, e.g.: g[r_ /; Head[r] === Real] := r + Pi ...


8

This also works: getHeads[g_] := DownValues[g][[All, 1, 1, 1]] /. Verbatim[Pattern][_, k_] :> k[[1]] Then: getHeads[g] {Integer, String}


5

f[g_] := Cases[First[#], Verbatim[Blank][x_] :> x, ∞] & /@ DownValues[g]



Top 50 recent answers are included