I have the following list:
list1 = {
{0, 0, 1496.11, 308.593}, {1, 0, 1168.02, 320.9}, {1, 1, 1161.97, 315.926},
{2, 0, 1287.57, 323.834}, {3, 0, 1618.89, 323.874}, {4, 0, 1251.01, 326.575},
{5, 0, 1474.81, 330.69}, {6, 0, 1181.24, 331.692}, {7, 0, 2431.87, 337.616},
{8, 0, 961.105, 340.223}, {9, 0, 1148.98, 344.855}, {9, 1, 1153.03, 336.984},
{10, 0, 1570.98, 346.771}, {11, 0, 1122.66, 349.883}, {11, 1, 1122.34, 351.845},
{11, 2, 1122.63, 353.678}, {11, 3, 1120.75, 351.175}, {11, 4, 1122.24, 358.885},
{11, 5, 1125.73, 360.05}, {11, 6, 1126.43, 362.175}
}
How can I manupulate list1 to receive list2 ;
list2 = {
{{0, 0, 1496.11, 308.593}},
{{1, 0, 1168.02, 320.9}, {1, 1, 1161.97, 315.926}},
{{2, 0, 1287.57, 323.834}},
{{3, 0, 1618.89, 323.874}},
{{4, 0, 1251.01, 326.575}},
{{5, 0, 1474.81, 330.69}},
{{6, 0, 1181.24, 331.692}},
{{7, 0, 2431.87, 337.616}},
{{8, 0, 961.105, 340.223}},
{{9, 0, 1148.98, 344.855}, {9, 1, 1153.03, 336.984}},
{{10, 0, 1570.98, 346.771}},
{{11, 0, 1122.66, 349.883}, {11, 1, 1122.34, 351.845}, {11, 2, 1122.63, 353.678},
{11, 3, 1120.75, 351.175}, {11, 4, 1122.24, 358.885}, {11, 5, 1125.73, 360.05},
{11, 6, 1126.43, 362.175}}
}
I tried to use a Do loop with If conditions and AppendTo but the code became terribly complicated.
Split[list1, First@#1 == First@#2 &]– Fred Simons Jun 29 '18 at 16:42