Feels like a strange question to ask, but I basically have a string with sets within sets, and it seems like the simplest formatting solution to seeing the data without needing to import everything into table or column form would be to replace every 7th comma in the string with \n to indent a new line. Mind you, this is the 7th itself starting from a count of 1 - not the 8th following 7. So starting from a count of 1, incrementing by 1 per count of a comma, all commas corresponding to a value where 'order' mod 7 = 0 would be replaced in the string by "\n". Is this a weird or nonsensical way of doing it? If I wanted to anyway, how would I implement what command generally?
Input
ps = Prime@Range[5, 16];
divs = x /. Solve[4 + x <= # && 1 + # <= 2 x, Primes] & /@ ps;
sets = MapThread[Thread[{#1, #2}] &, {ps, divs}];
results =
Map[With[{p = #[[1]],
x = #[[2]]}, (((Binomial[Reverse[Range[((p + 1)/2), (p - 3)]],
Range[(p - 3) - ((p + 1)/2) + 1]])))/x] &, sets, {2}];
matches =
ReplaceList[
Flatten[MapThread[Transpose[{##}] &, {sets, results}],
1], {___, {{p1_, d1_}, {pre1___, val1_, ___}}, ___, {{p2_,
d2_}, {pre2___, val2_, ___}}, ___} /;
d1 == d2 && val1 == val2 && Length@{pre1} < Length@{pre2} :>
With[{r1 = Length@{pre1} + 2,
r2 = Length@{pre2} + 2}, {d1, {p1, r1}, {p2, r2},
val1, (r2 - (r1 + ((r2 - r1)/2)))}]]
Output
{{13, {17, 4}, {23, 10}, 220/13, 3}, {17, {23, 6}, {29, 12}, 4368/17, 3}, {19, {23, 6}, {29, 12}, 4368/19, 3}, {23, {29, 6}, {41, 18}, 26334/23, 6}, {29, {41, 12}, {47, 18}, 21474180/29, 3}, {29, {41, 10}, {53, 22}, 493350, 6}, {31, {41, 12}, {47, 18}, 21474180/31, 3}, {31, {41, 10}, {53, 22}, 14307150/31, 6}, {37, {41, 12}, {47, 18}, 21474180/37, 3}, {37, {41, 10}, {53, 22}, 14307150/37, 6}, {29, {47, 14}, {53, 20}, 11978400, 3}, {31, {47, 14}, {53, 20}, 11205600, 3}, {37, {47, 14}, {53, 20}, 347373600/37, 3}, {41, {47, 14}, {53, 20}, 347373600/41, 3}, {43, {47, 14}, {53, 20}, 347373600/43, 3}}
Column[matches]
and evaluate it - it gives each set on its own line - is that not what you're after? $\endgroup$