making sub list from a list

I have a list

{{1, 2, 3, 4}, {1, 2, 4, 3}, {1, 3, 2, 4}, {1, 3, 4, 2}, {1, 4, 2,3},
{1, 4, 3, 2}, {2, 1, 3, 4}, {2, 1, 4, 3}, {2, 3, 1, 4}, {2, 3,4, 1},
{2, 4, 1, 3}, {2, 4, 3, 1}, {3, 1, 2, 4}, {3, 1, 4, 2}, {3, 2, 1, 4},
{3, 2, 4, 1}, {3, 4, 1, 2}, {3, 4, 2, 1}, {4, 1, 2, 3}, {4, 1, 3, 2},
{4, 2, 1, 3}, {4, 2, 3, 1}, {4, 3, 1, 2}, {4, 3, 2, 1}}


I want to make them this way- {{{1, 2}, {3, 4}}, {{1, 2}, {4, 3}},...

Which code should I use?

• ArrayReshape, Partition etc. – Kuba Aug 20 '17 at 9:52
• list // {#[[All, ;; 2]], #[[All, -2 ;;]]} & // Transpose  and TakeDrop[#, 2] & /@ list are other possibilities. – user1066 Aug 20 '17 at 12:40

Besides Partition and Map (/@), you can also use ArrayReshape:

ArrayReshape[list, {Length@list, 2, 2}]


One way is to partition each element in your list into a list of two elements:

Partition[#, 2] & /@ list


Where list is your example list.

list = {{1, 2, 3, 4}, {1, 2, 4, 3}, {1, 3, 2, 4}};

list /. {a_, b_, c_, d_} :> {{a, b}, {c, d}}


or

{{#1, #2}, {#3, #4}} & @@@ list


both give

{{{1, 2}, {3, 4}}, {{1, 2}, {4, 3}}, {{1, 3}, {2, 4}}}