0
$\begingroup$

I'm pretty sure I should be using BinLists[...] but it doesn't behave quite as I expect. Say I have a list of data : Data = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,...}

I want to be able to chop this data into blocks of a certain size, e.g. {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{..}} for blocks of three, or, {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16},{...}} for blocks of four

I try using BinLists[Data,3] but this seems to be out of order giving me {{1,2},{3,4,5},{6,7,8},{9,10,11},{12,13,14},...} rather than in the form I described above.

Is there a way to modify BinLists[...] in some way or an alternative that will achieve what I want.

Thanks

$\endgroup$

closed as off-topic by Edmund, MarcoB, PlatoManiac, m_goldberg, J. M. is away Aug 20 '17 at 3:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Edmund, MarcoB, PlatoManiac, m_goldberg, J. M. is away
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Have you seen Partition? $\endgroup$ – Edmund Aug 19 '17 at 2:43
  • 2
    $\begingroup$ BinLists start counting from 0, that's why there are only 2 elements in {1,2} $\endgroup$ – Alucard Aug 19 '17 at 2:58
  • $\begingroup$ @Edmund no I had not seen this fucntion, thanks very much!! $\endgroup$ – QuantumPenguin Aug 19 '17 at 10:48
2
$\begingroup$
Partition[Data,4]

or

Partition[Data,3]

if you want to use BinLists write

BinLists[data, {First@data, Last@data, 3}]
$\endgroup$
  • $\begingroup$ wonderful! Thank you! $\endgroup$ – QuantumPenguin Aug 19 '17 at 10:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.