I often need to combine several vectors into an array of structures where the i-th element of the array of structures corresponds to the i-th elements of each of the vectors.
For example, if I have three vectors of differing data types:
IDL> x = indgen(3) + 1 IDL> names = ['Mike', 'George', 'Bill'] IDL> values = 100.0 * randomu(seed, 3)
And I want to combine them into a single array of structures for printing, I can do:
IDL> print, mg_zip(x, names, values), format='(%"%02d. %-15s: %6.2f")' 01. Mike : 3.22 02. George : 43.89 03. Bill : 97.14
This part of a growing collection of routines I have to manipulate tabular data, centered around an
mg_table class. The code for
mg_zip is in
src/tables directory of the mglib repo.
More to come on tables…