Re: HoldForm
- To: mathgroup at smc.vnet.net
- Subject: [mg68099] Re: HoldForm
- From: "J Siehler" <jsiehler at gmail.com>
- Date: Mon, 24 Jul 2006 00:55:41 -0400 (EDT)
- References: <e9v992$gjr$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
> This code displays the component differences of matrix subtraction (A-B):
> A = {{1, 2}, {3, 4}};
> B = {{5, 6}, {7, -8}};
> Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2]
> As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}.
> Two questions:
> - What's a better way to do this?
> - How can I replace the -- by +?
A={{1,2},{3,4}};
B={{5,6},{7,-8}};
inertPlus[l___]:=HoldForm[Plus[l]]
SetAttributes[inertPlus,Listable]
inertPlus[A,-B]
{{1-5,2-6},{3-7,4+8}}