When applying some arithmetic operation on two lists, I'd like to display the actual operations between the elements of each list. For example, {1, 1} + {1, -1}
would display {1 + 1, 1 - 1}
.
With simple operations, I could just use Trace
and pick out the part with the right form:
Trace[{1, 1} + {1, -1}, {_Plus, _Plus}]
(* {{1+1,1-1}} *)
However, this becomes really cumbersome in more complex operations. Even worse, some operations don't even show element-by-element operations within Trace
.
Trace[{{1, 2}, {3, 4}}.{{5, 6}, {7, 8}}]
(* {{{1,2},{3,4}}.{{5,6},{7,8}},{{19,22},{43,50}}} *)
This is what I actually want to display:
Of course I could programmatically display the element operation of the matrix multiplication above, but I have to do the same for every other matrix operations.
My question is: Is there a straightforward way to display operations on elements of two lists? Please feel free to add your own examples and make it as general as you want to.
Comments
Post a Comment