MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to Properly Use Partition?

  • To: mathgroup at
  • Subject: [mg36728] Re: How to Properly Use Partition?
  • From: Tom Burton <tburton at>
  • Date: Sat, 21 Sep 2002 02:21:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hello Flip,

On 9/20/02 1:22 AM, in article amem4s$41p$1 at, "flip"
<flip_alpha at> wrote:

> What I want is a function that takes a string as input, parses each
> character, partitions that to whatever length I want and Prepends zeros to
> the input as needed to create an appropriate length array.
> What is the correct syntax for Partition (or is there a better way?).

Although you can't see it in your particular example, I think your two
Reverse functions would lead to reversed partitions, so I got rid of them.
Then it's a matter of following directions for Partition in Help. The only
issue is computing kL. The following way is a bit complicated. Perhaps
someone will post a simpler way.

n = "10101111"; 
r = 3; 
p = Characters[n]; 
kL = r + 1 - Mod[Length[p], r, 1];
kR = r; 
z = Partition[p, r, r, {kL, kR}, "0"]

Tom Burton

  • Prev by Date: Mathematica 4.2 on Solaris 6?
  • Next by Date: RE: Could someone verify a long Pi calculation in Version 4 for me?
  • Previous by thread: How to Properly Use Partition?
  • Next by thread: RE: How to Properly Use Partition?