# Dividing data into blocks define sizes [closed]

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

• Have you seen Partition? – Edmund Aug 19 '17 at 2:43
• BinLists start counting from 0, that's why there are only 2 elements in {1,2} – Alucard Aug 19 '17 at 2:58
• @Edmund no I had not seen this fucntion, thanks very much!! – Q.P. Aug 19 '17 at 10:48

Partition[Data,4]


or

Partition[Data,3]


if you want to use BinLists write

BinLists[data, {First@data, Last@data, 3}]

• wonderful! Thank you! – Q.P. Aug 19 '17 at 10:48