I am trying to get a With
/ Module
pair to return a set of functions.
Funky[n_] := With[{x = n},
Module[{LocalFunc1, LocalFunc2, MkLocalFunc},
LocalFunc1[y_] := x + y;
LocalFunc2[y_] := x - y;
MkLocalFunc[_fnToUse] := With[{UseLocalFunc = fnToUse},
Module[{LocalFunc},
LocalFunc[w_] = UseLocalFunc[w] + 10;
LocalFunc
]
];
{MkLocalFunc[LocalFunc1], MkLocalFunc[LocalFunc2]}
]
]
(Funky[1] // First)[1]
Here I expected the output to be 12
but it returns MkLocalFunc$636015[LocalFunc1$636015][1]
Why won't it evaluate MkLocalFunc$636015
?
MkLocalFunc[_fnToUse]
part is a little odd; this basically restrictsMkLocalFunc[]
to only evaluate on anything with anfnToUse
head. I wonder ifMkLocalFunc[fnToUse_]
was intended instead, considering theWith[]
that follows... $\endgroup$