Re: Exercise of Programming with Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg131962] Re: Exercise of Programming with Mathematica
- From: Douglas Skinner <d_dubya_skinner at hotmail.com>
- Date: Wed, 6 Nov 2013 00:37:44 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <l3qrmm$3ps$1@smc.vnet.net>
Here's a solution which uses a postfix function. (Though I think Bill Rowe's solution is far more elegant.) In[25]:= {{a, b}, {c, d}} // Reverse[#, {2}] & (* works for a list of two *) Out[25]= {{b, a}, {d, c}} In[26]:= {{a, b}, {c, d}, {e, f}} // Reverse[#, {2}] & (* works also for 3 *) Out[26]= {{b, a}, {d, c}, {f, e}, {h, g}}