*In[1]=* Transpose[{a, b}]
returned in earlier versions of Mathematica (e.g Mathemtica 12.1) simply
*Out[1]=* Transpose[{a, b}]
together with the warning: "Transpose::nmtx: The first two levels of {a,b} cannot be transposed."
However in Mathematica 12.2 (on Windows10) the output is:
*Out[1]=* {a,b}
The Transpose has disappeared. Is this a bug or a feature?
For me, it is problem, because this new behavior is breaking my existing code, where I have functions similar to:
getfromdatabase[key_String]:=CallToCppCodeAndReturnListsOfValues[key]
getfromdatabase[expr_]:=expr/. key_String :> getfromdatabase[key]
In previous versions (<12.2) users of my code could execute
getfromdatabase[ Transpose[{"firstname", "lastname", "salary"-"rent"}] ]
and the output was for example:
{ {David, Smith, somenumber}, {Lisa, Garbo, someothernumber}, ... }
Now, in 12.2, one gets:
{ {David, Lisa,...}, {Smith, Garbo, ...}, {somenumber, someothernumber, ...}}
How can I change getfromdatabase to get back the old output using the same input as before?
(Sure, in the example above, one could apply Transpose after calling the function. But in other calls there might be calls of Transpose more nested inside the expression, like getfromdatabase[ Transpose[{"firstname", "lastname", Transpose[{"salary","rent"}]] ]
)
Thanks!
Transpose[{}]
is{}
, which for me was a very welcome change. Note thatTranspose[{{}}]
is{}
. $\endgroup$Transpose[{1, 2, 3}]
showed an error message in previous versions. Relying on specific details of how an error was handled before just isn't a good idea. $\endgroup$HoldAll
won't work in this case. $\endgroup$