|
[Date Index]
[Thread Index]
[Author Index]
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
>ideas leading to
>a possibly simpler solution.
>
>Thanks, Mariusz
>
Mariuz,
PadRight still going strong:
In[1]:= r = {a, b, c, d};
In[2]:= rr = Join[r, Reverse[r]]
Out[2]= {a, b, c, d, d, c, b, a}
In[3]:= PadRight[rr, 14, rr]
Out[3]=
{a, b, c, d, d, c, b, a, a, b, c, d, d, c}
In[4]:= PadRight[rr, 8, rr, 2]
Out[4]=
{b, a, a, b, c, d, d, c}
--
Hartmut Wolf
Prev by Date:
Re: Anyone using the Units package extensively?
Next by Date:
Re: Anyone using the Units package extensively?
Previous by thread:
Padding arrays with reversed elements
Next by thread:
jlink function argument
|