Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Partitioning a list from an index

  • To: mathgroup at
  • Subject: [mg56931] Re: [mg56890] Partitioning a list from an index
  • From: yehuda ben-shimol <bsyehuda at>
  • Date: Tue, 10 May 2005 03:42:47 -0400 (EDT)
  • References: <>
  • Reply-to: yehuda ben-shimol <bsyehuda at>
  • Sender: owner-wri-mathgroup at

Hi Guy,
As I understand your description the following function does what you
asked for (the arguments are self explanatory):
    pos_Integer, len_Integer, pad_:{}] := Partition[l, len, len, {pos - 
    1, 1}, pad] /. {a_, b__, c_} :> {Sequence @@ a, b, Sequence @@ c}

On 5/9/05, Guy Israeli <guyi1 at> wrote:
> hello,
> how can partition a list (doesn't have to be with 'Partition') such that the
> partition will begin with a specific index?
> like this:
> list1={1,2,3,4,5,6,7,8,9,10}
> and i might want to split it to pairs or threes from index 6 for example, so
> for threes it will be
> {1,2,{3,4,5},{6,7,8},9,10}
> with or without padding to those that are left, depends on what it is
> possible, or maybe put them together or something
> for pairs it will be {1,{2,3},{4,5},{6,7},{8,9},10}
> again with or without padding
> thank you very much
> Guy

  • Prev by Date: Re: NSum: badly missed Option
  • Next by Date: Re: Mathematica and RC circuits
  • Previous by thread: Partitioning a list from an index
  • Next by thread: Re: Partitioning a list from an index