Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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

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

share|improve this answer
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? – Tyler Durden Dec 7 '13 at 0:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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