MapIndexed[List, $Path] // Reverse /@ # & // TableForm
How to use Mathematica and the Wolfram Langage - for beginner, intermediate, and advanced users.
Thursday, February 9, 2012
Numbering Things with MapIndexed
Sometimes you just want to number a List or Parts of an Expression. For example, I often want to number things that I'm putting into TableForm. Here's a simple idiom using MapIndexed. MapIndexed puts the indices as the second Part of each Expression, which the Reverse clause reverses so the number appear as the first column in TableForm.
MapIndexed[List, $Path] // Reverse /@ # & // TableForm
MapIndexed[List, $Path] // Reverse /@ # & // TableForm
RSI^2: Recursive Safety Improvement: Apply AI to its own safety R&D
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment