How to Properly Use Partition?
- To: mathgroup at smc.vnet.net
- Subject: [mg36737] How to Properly Use Partition?
- From: "Dana DeLouis" <delouis at bellsouth.net>
- Date: Sat, 21 Sep 2002 02:22:06 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I believe this will work. The {1,1} uses overhang at the end, and the 0
is the character to use.
P = {"1", "1", "1", "1", "0", "1", "0", "1"}
Reverse[Partition[p, 3, 3, {1, 1}, 0]]
{{"0", "1", 0}, {"1", "0", "1"}, {"1", "1", "1"}}
--
Dana DeLouis
Windows XP
$VersionNumber -> 4.2
= = = = = = = = = = = = = = = = =
"flip" <flip_alpha at safebunch.com> wrote in message
news:amem4s$41p$1 at smc.vnet.net...
> 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.