Trouble Transposing Arrays that Contain Lists

I'm trying to transpose an array with the following general format.

Snag_1f244195

Using the Transpose block results in something that looks like this:

Snag_1f25fd9d

Where:
Snag_1f2775e5

and
Snag_1f28383b

Instead, I expected item 1 of the transposition to be a list containing two lists, "A, B" in the first column and then "C, D" in the second. I expected item 2 of the transposition to be a list containing the numbers "1" and "2".

I've used the transpose block before, but never on an array that's nested like this. Clearly there's something about the process that I'm not understanding. Does anyone have any thoughts on what's going on here and how I might be able to achieve the desired result?

Thanks.

Welcome back!

Try

.

Bleagh, this is a bug, I guess. TRANSPOSE assumes that its input is a uniformly filled array, i.e., if the maximum depth of the list is 3, as in your case, that all the atoms are at depth 3.

And what it does is reverse the order of the indices of each atom. So, in your list, B is list[1,1,2], so it should be at transposed[2,1,1], and indeed it is.

So for example, the transpose of
(((a b) (1 2)) ((c d) (3 4)))
is
(((a c) (1 3)) ((b d)) (2 4)))

But TRANSPOSE gets confused because some of the atoms, namely the numbers, are only at depth 2.

I think that what it should do is fill your array by turning it into
(((a b) (1 1)) ((c d) (2 2)))
and then it'll know how to transpose that.

You're expecting it to transpose only the first two of the three dimensions. As @warped_wart_wars points out, the COLUMNS block does that.

Let me work on this and report back...

@warped_wart_wars, Beautiful. Thanks!

@bh I suspected something like that was going on, but I wasn't familiar enough with deeper arrays to suss it out completely. Your explanation helps quite a bit. Thanks.

You're welcome.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.