I'm implementing a function
tacit1 that constructs a pure function by applying all
tacit1[IntegerPartitions[Max, Length/2, Select[Most, # < 10&]]] (* IntegerPartitions[Max[#], Length[#]/2, Select[Most[#], # < 10&]]& *)
However, I also need the ability to escape symbols, say with a head
tacitVerbatim, so that
tacit1 does not enter expressions with head
Compose and other higher-order functions should automatically be excluded too.)
tacit1[SortBy[Most, tacitVerbatim[ Abs @* Sin]]] (* SortBy[Most[#], Abs @* Sin]& *)
I tried the answer to How to ReplaceAll except within specified heads, but
ReplaceAll enters Heads by default, and tries to replace the
IntegerPartitions head with
IntegerPartitions[#]. I also need to specify levels to keep the outer
Function from being replaced.
Replace examines expressions from deepest to shallowest, so the trick that keeps
ReplaceAll out of certain expressions doesn't work.
I'm thinking of manually searching the expression tree, but is there a more elegant idea?