# Redefine a function on certain values

This question is related to Zero-dimensional matrices, in particular to the answer https://mathematica.stackexchange.com/a/39543/42722.

In Mathematica $$0 \times n$$-matrices are not well-defined, so I extended the definitions of Dimensions, Dot, Transpose ,Join, ... to a function emptyMatrix[n], which should represent an $$0 \times n$$-matrix for $$n\geq 0$$.

For example, we have Transpose[emptyMatrix[n]]=ConstantArray[{},n] and so on. This works all quite well, except that Transpose[ConstantArray[{},n]] in Mathematica gives {}, so in this case I need to redefine (instead of simply extending) the function Transpose on $$n \times 0$$-matrices.

Is this possible?

• Do you absolutely need to use system functions? Otherwise this will do transpose[expr_] := Transpose[expr]; transpose[list : {{} ..}] := emptyMatrix[Length[list]]; Mar 18, 2020 at 10:36
• aha, I didn't think of that.. thx! probably I don't need system functions. If Transpose is used in some other system function I'm using, then I could do the same trick again, I guess Mar 18, 2020 at 10:40
• The alternative is to Unprotect and use the same definition on Transpose. I won't make any promise on that not introducing weird bugs though =) Mar 18, 2020 at 10:52