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...
$\begingroup$
$\endgroup$
1
-
1$\begingroup$ Related (probably not a dupe because no explicit numbering is requested): mathematica.stackexchange.com/q/47164/131. Fancy: mathematica.stackexchange.com/a/21122/131 $\endgroup$– Yves KlettCommented Dec 22, 2014 at 14:07
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
1
TableForm
does the trick:
array = {{"a", "b", "c", "d"}};
TableForm[array, TableHeadings -> {None, Automatic}]
More flexible would be a MapIndexed
-based solution:
Grid[MapIndexed[{#2[[1]], #} &, array[[1]]] // Transpose,
Frame -> All]
-
$\begingroup$ Ah, I found
TableForm
, but did not see theTableHeadings
modifier. Thanks! $\endgroup$ Commented Dec 22, 2014 at 13:49