2D arrays

@chips-a-hoai - For multi-array style data structures, your above summary more-or-less captures your options in VENUS.

I don’t know if I am spoiling a secret here, but there is actually no such thing as a 2D array in VENUS. The 2D array library of HSL extensions instantiates a standard static array whose size is dictated by x ‘rows’ by y ‘columns’. So if you wanted 3 rows by 10 columns, all it does is generate an array of 30 elements. This is why that library requires the ‘arrays’ to be of conserved size (which isn’t always convenient).The library functions just provide convenience for managing the indexing when storing and getting values out of the array.

In order to store multi-array style data, you will need to program a couple extra intermediate style processing steps as you alluded to. One of the options I have gravitated to over the years when I need to process higher level data structures are dictionaries, which you have mentioned. In VENUS dictionaries are convenient as they support various variant types (int, flt, str etc) without having to be converted.

Another technique I have used in VENUS is to collapse an array of elements into a delimited string (via ‘JoinWithDelimiter’ of the HSLExtensions String library) which can then be managed as a single array element in an ‘array of arrays’, where the array of arrays is simply an array of delimited strings (where each element can maintain the data of an array of any size). To convert the delimited string elements back into an array format for further processing, you simply use the ‘Split’ function of the HSLExtensions String library. This is especially convenient when processing strings, but if not, you will need to convert variable types to and from strings.

Often times I have mixed the above technique with dictionaries in order to achieve complex data structure processing. The tradeoff is that you can dynamically dictate and process any schema you want, but will require you to do additional programming.

-Nick

5 Likes