I have a problem I'm trying hard to find a solution for, although I don't know if a solution exists.
The following rules produce the result
x_G . f ^:= x G[x_, ___, y_] := y[x] G[2, e] . f
Would it be possible to get
e instead ?
I'm not sure it's possible as
x in the left hand side of the definition of
f is copied to the right hand side after having been evaluated. A solution would be to put a temporary
HoldFirst attribute to
Dot but this has undesirable side effects on the language.
Basically the usage I'm looking for is that an expression of the form
G[x_, ____ , y_ ] is transformed to y[x], but not if it's part of an expresion of the form
G[____].f[___], where in this case an UpValue should first be used, but the
DownValues transformation to
y[x] can happen in the rhs of
Would analyzing the stack help maybe? I tried that without success.