MathGroup Archive 2002

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

Search the Archive

How to Properly Use Partition?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36725] How to Properly Use Partition?
  • From: "flip" <flip_alpha at safebunch.com>
  • Date: Fri, 20 Sep 2002 04:16:49 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

b = 2; r = 4;
n = "10101111"
p = Reverse[Characters[n]]
{"1", "1", "1", "1", "0", "1", "0", "1"}
z = Reverse[Partition[p, r]]
{{"0", "1", "0", "1"}, {"1", "1", "1", "1"}}  (* this is okay *)
b = 2; r = 3;
z = Reverse[Partition[p, r]]
{{"1", "0", "1"}, {"1", "1", "1"}}  (* this is wrong, want output to be
{{0,1,0},{1,0,1},{1,1,1}}*)

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?).

Thanks, Flip

Remove _alpha to email.




  • Prev by Date: Re: build-in commutativity
  • Next by Date: Re: the meaning of a exponential plot in the negative region
  • Previous by thread: RE: Re: build-in commutativity
  • Next by thread: Re: How to Properly Use Partition?