New answers tagged

0

I know of no method to achieve the specific syntax and evaluation that you want that I would recommend in practice. However for the sake of discussion a way to avoid the unwanted evaluation of the argument is to only define UpValues on f, which only evaluates f[x] when it has some surrounding expression. To get evaluation of a bare input/output we need ...


2

I don't think up-values are the way to go. I think you should write a new function, say diag, that has a special behavior for f, but works like Diagonal for any other args. Something like f[x_] := x.Transpose[x] f[x_, Diagonal -> True] := Diagonal[x] SetAttributes[diag, HoldAllComplete] diag[f[x_]] := f[x, Diagonal -> True] diag[args___] := Diagonal[...



Top 50 recent answers are included