MathGroup Archive 2002

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

Search the Archive

How to Properly Use Partition?


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?