From: Robert D. <rob...@gm...> - 2023-08-14 19:53:43
|
I'm working on a function to reshape a list (possibly nested) into another possibly-nested list. See: https://github.com/maxima-project-on-github/maxima-packages in the folder robert-dodier/reshape . reshape only works on lists at present, although handling matrices and arrays would be plausible extensions. I'll finish the list stuff first and then think about other types. So far the new list is filled by rows (first index varies slowest). I'm also contemplating filling by columns (first index varies fastest) although the indexing seems to be more complicated and I haven't got it right -- stay tuned, I might need some help with that. reshape recognizes 'any in the list of new dimensions, to represent a dimension which is inferred. Left-over elements aren't allowed -- the input and output will have the same number of elements. Any number of dimensions, including one, is allowed for the output. As special cases, reshape(x, ['any, 2]) divides x into pairs, likewise reshape(x, ['any, 3]) divides x into triples. The test script, https://github.com/maxima-project-on-github/maxima-packages/blob/master/robert-dodier/reshape/rtest_reshape.mac has a number of examples. Hope this is of some interest; any comments are welcome. Robert |