Below, there is an example how I tried to call the compiled function "position" (which i got from this link position) inside another one.
position = Compile[{{mat, _Integer, 2}, {elm, _Integer, 0}}, Module[{result = Internal`Bag[Most[{0}]], i, j},
Table[If[mat[[i, j]] === elm,
Internal`StuffBag[result, Internal`Bag[{i, j}]]], {i,
Length[mat]}, {j, Length[First[mat]]}];
Table[
Internal`BagPart[pos, {1, 2}], {pos,
Internal`BagPart[result, All]}]], CompilationTarget -> "C", RuntimeOptions -> "Speed"];
Now, I try to call the position function inside another and I do this with the "With"-function.
Ex = With[{pos = position}, Compile[{{G0, _Real, 2}}, Module[{G = G0, P, n, p},
P = {2, 5, 1, 6};
n = Length[G];
p = pos[G, #] & /@ {P[[2]], P[[3]]};
], CompilationTarget -> "C",
CompilationOptions -> {"InlineCompiledFunctions" -> True}]];
My question is, whether there is another way of calling a compiled function inside another, maybe without defining this variable "pos" at the beginning?