RE: Padding arrays with reversed elements

• To: mathgroup at smc.vnet.net
• Subject: [mg45685] RE: [mg45636] Padding arrays with reversed elements
• From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
• Date: Mon, 19 Jan 2004 05:15:30 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```>-----Original Message-----
>From: Mariusz Jankowski [mailto:mjankowski at usm.maine.edu]
To: mathgroup at smc.vnet.net
>Sent: Saturday, January 17, 2004 1:57 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg45685] [mg45636] Padding arrays with reversed elements
>
>
>Hi all, a recently posted question on "creating a toroidal
>data structure"
>and the the responses have inspired me to post the following
>similar but
>harder problem. I am interested in "reflected" padding of
>multidimensional
>arrays. Here is an example in 1D:
>
>{a,b,c,d} -> {a,b,c,d,d,c,b,a,a,b,c,d,d,c, etc}
>
>also the padding should be possible on the left or right or both and of
>course, the length is an argument. I have a complicated
>looking solution
>using PadRight, Fold, Partition and would love to see some
>a possibly simpler solution.
>
>Thanks, Mariusz
>

Mariuz,

In[1]:= r = {a, b, c, d};

In[2]:= rr = Join[r, Reverse[r]]
Out[2]= {a, b, c, d, d, c, b, a}

Out[3]=
{a, b, c, d, d, c, b, a, a, b, c, d, d, c}