Categories
Development

Encode Python lists as indexes of unique values

I’d like to represent an arbitrary list as two other lists. The first, call it values, containing the unique elements in the original list, and the second, call it codes, containing the index in values of each element in the original list, in such a way that the original list could be reconstructed as orig_list […]