All you have to do is to be consistent about using only expressions as arguments to the operator, not function heads. The reason is that the operator as you define it returns an expression and not a function. That's why you then cannot apply the operator twice. But by working only with expressions, this problem is avoided:
xleft = Function[f, D[f, x] - y D[f, z]/2];
xleft[f[x, y, z]]
$f^{(1,0,0)}(x,y,z)-\frac{1}{2} y
f^{(0,0,1)}(x,y,z)$
xleft[xleft[f[x, y, z]]]
$-\frac{1}{2} y
f^{(1,0,1)}(x,y,z)-\frac{1}{2} y
\left(f^{(1,0,1)}(x,y,z)-\frac{1
}{2} y
f^{(0,0,2)}(x,y,z)\right)+f^{(2,
0,0)}(x,y,z)$
Now you can apply the operator as many times as you like. The only difference in the application is that the argument f
has to be replaced by f[x,y,z]
.
Alternatively (but I'd prefer the first approach), you could also work only with functions and not with expressions:
Clear[xleft];
xleft = Function[f,
Function[{x, y, z}, D[f[x, y, z], x] - y D[f[x, y, z], z]/2]];
xleft[xleft[f]][x, y, z]
$-\frac{1}{2} y
f^{(1,0,1)}(x,y,z)-\frac{1}{2} y
\left(f^{(1,0,1)}(x,y,z)-\frac{1
}{2} y
f^{(0,0,2)}(x,y,z)\right)+f^{(2,
0,0)}(x,y,z)$
Here, the operator returns a function but then you have to evaluate the result by giving it back the arguments at the end.