This works fine when put in a notebook:
TestFunction2[x_] := Column[{Head /@ x, Cases[x, _f], MatchQ[_f] /@ x}];
TestFunction2[{f[1, 2]}]
and produces:
{f}
{f{1,2}}
{True}
However if the function is put in a package, for example:
BeginPackage["Test`"]
TestFunction::usage=""
Begin["`Private`"]
TestFunction[x_]:=Column[{Head/@x,Cases[x,_f],MatchQ[_f]/@x}];
End[]
EndPackage[]
and then used from a notebook:
Needs["Test`"];
TestFunction[{f[1, 2]}]
it produces:
{f}
{}
{False}
Why?
Edit:
My example was not detailed enough to explain what I want to achieve. I indeed want to have f that is defined in the context of Test`. This is because I want to use it as a type inside the package Test.
This is for example because I want to distinguish between two different arrays and wrap one of them for example in f[{1,2,3}] and another one in g[{1,2,3,}] and thus make distinction how they should be processed in Test.
fis created asTest`Private`finTestFunction, but you are matching againstGlobal`f– Szabolcs Apr 05 '17 at 13:03