1
$\begingroup$

I have a triangular list of lists as follows:

In[54]:= Tally[IntegerPartitions[#][[All,1]]][[All,2]]&/@Range[20]
Out[54]= {{1},{1,1},{1,1,1},{1,1,2,1},{1,1,2,2,1},{1,1,2,3,3,1},{1,1,2,3,4,3,1},{1,1,2,3,5,5,4,1},{1,1,2,3,5,6,7,4,1},{1,1,2,3,5,7,9,8,5,1},{1,1,2,3,5,7,10,11,10,5,1},{1,1,2,3,5,7,11,13,15,12,6,1},{1,1,2,3,5,7,11,14,18,18,14,6,1},{1,1,2,3,5,7,11,15,20,23,23,16,7,1},{1,1,2,3,5,7,11,15,21,26,30,27,19,7,1},{1,1,2,3,5,7,11,15,22,28,35,37,34,21,8,1},{1,1,2,3,5,7,11,15,22,29,38,44,47,39,24,8,1},{1,1,2,3,5,7,11,15,22,30,40,49,58,57,47,27,9,1},{1,1,2,3,5,7,11,15,22,30,41,52,65,71,70,54,30,9,1},{1,1,2,3,5,7,11,15,22,30,42,54,70,82,90,84,64,33,10,1}}

I want to display each member of the list in a column (ideally with # as the column heading). I tried using Column, Transpose and Inverse to no avail.

$\endgroup$
  • $\begingroup$ With the output of the Tally called q, does TableForm[q] do what you wish? $\endgroup$ – bill s Dec 7 '13 at 0:12
  • $\begingroup$ Is this what you're looking for, provided the ragged array is named ragged? Table[ragged[[i ;;, i]], {i, 1, Length@Last@ragged}] $\endgroup$ – Szabolcs Dec 7 '13 at 0:16
  • $\begingroup$ It may be a duplicate of this $\endgroup$ – Szabolcs Dec 7 '13 at 0:24
  • $\begingroup$ TableForm results in each sublist being presented in a row, not a column. $\endgroup$ – Tyler Durden Dec 7 '13 at 0:24
3
$\begingroup$

For simply transposing a ragged array, see Transpose uneven lists

For displaying various transpositions both as upper or lower triangular formats, pad the array before display:

Transpose@PadRight[ragged, {Length[ragged], Length@Last[ragged]}, ""] // TableForm

enter image description here

$\endgroup$
  • $\begingroup$ I tried Flatten[Tally[IntegerPartitions[#][[All, 1]]][[All, 2]] & /@ Range[20] // Reverse, {2}] // TableForm and it almost worked (columns were reverse ordered). Is Ragged/Transpose better than Flatten? $\endgroup$ – Tyler Durden Dec 7 '13 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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