Re: A bug in Partition?
- To: mathgroup at smc.vnet.net
- Subject: [mg117431] Re: A bug in Partition?
- From: Ray Koopman <koopman at sfu.ca>
- Date: Fri, 18 Mar 2011 06:01:02 -0500 (EST)
- References: <ilsri1$t4b$1@smc.vnet.net>
On Mar 17, 4:33 am, "Alexey Popkov" <lehi... at gmail.com> wrote: > My second question is: is there universal way to pad partitioning list at > the start without dropping any elements? I mean the same way as in the case > of padding at the end. The solution I currently use is just a workaround: > > list = {a, b, c, d, e, f, g, i}; > Reverse /@ Reverse@Partition[Reverse@list, 3, 3, 1, x] > > Alexey Use k = -Mod[Length@list, n, 1] Partition[Range@7, 3,3, -1, 0] Partition[Range@8, 3,3, -2, 0] Partition[Range@9, 3,3, -3, 0] {{0,0,1},{2,3,4},{5,6,7}} {{0,1,2},{3,4,5},{6,7,8}} {{1,2,3},{4,5,6},{7,8,9}}