Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: How to Properly Use Partition?

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

Hello Flip,

On 9/20/02 1:22 AM, in article amem4s$41p$1 at smc.vnet.net, "flip"
<flip_alpha at safebunch.com> 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?