arrow icon indicating copy to clipboard operation
arrow copied to clipboard

Counter-intuitive behavior of `unweave` in Iterable / Sequence

Open theycome opened this issue 5 months ago • 0 comments

Say we have 3 initial collections (after transformations)

[16, 17, 18]
[3, 4]
[5, 6]

and then we want to unweave.. but what does it mean? Probably we wanted to interleave all 3 collections? If so, then the output should be [16, 3, 5, 17, 4, 6, 18]

But current unweave does something quite strange - it starts from the last two collections and then moves backwards interleaving them. So first we have [3, 4] interleave [5, 6] -> [3, 5, 4, 6] then we get to the first element and [16, 17, 18] interleave [3, 5, 4, 6] -> [16, 3, 17, 5, 18, 4, 6] Is this the original intent?

Also the recursion approach used in implementation might be slow.. ?

theycome avatar Jul 23 '25 22:07 theycome