Is it possible to construct an argument such that any function applied to this argument returns itself, i.e. (the slot is used to allow for additional arguments in the function)
x = getfunc;
anyfunction[x]
(* Out: anyfunction[#]& *)
More specifically, I like to use an existing function in various places of the argument without changing the function. E.g. if x is a list, I want any function which is applied to x to be mapped on x without changing the function by using Map, i.e. something like
x = {getfunc@a, getfunc@b}
anyfunction[x]
(* Out: {anyfunction[#]&[a],anyfunction[#]&[b]} *)
getfunc /: anyfunc_[getfunc[x_]] := anyfunc[#] &I can solve the problem:anyfunc[getfunc[x]]returnsanyfunc[#]&. Modifying the right-hand side can then solve all other related problems like my example withMap. – Passi Jun 06 '18 at 15:05##would allow additional arguments, just likeanyfunctionalone. – Kuba Jun 06 '18 at 16:21getfunc /: anyfunc_[getfunc[x_], opt___] := anyfunc[#, opt] &which is a trivial extension. – Passi Jun 06 '18 at 16:32