6

Is there a single function that prints an array together with the indices? I know how to achieve this with Grid[{Range[n],array},Frame->All], but I vaguely recall there is a special function that achieves this? I am not finding it via searches...


Array
Joseph O'Rourke
  • 4,731
  • 25
  • 42
  • 1
    Related (probably not a dupe because no explicit numbering is requested): http://mathematica.stackexchange.com/q/47164/131. Fancy: http://mathematica.stackexchange.com/a/21122/131 – Yves Klett Dec 22 '14 at 14:07

1 Answers1

6

TableForm does the trick:

array = {{"a", "b", "c", "d"}};

TableForm[array, TableHeadings -> {None, Automatic}]

Mathematica graphics

More flexible would be a MapIndexed-based solution:

Grid[MapIndexed[{#2[[1]], #} &, array[[1]]] // Transpose, 
 Frame -> All]

Mathematica graphics

Yves Klett
  • 15,383
  • 5
  • 57
  • 124