Is this what you’re wanting:
use script "List"
transpose list {{1, 2, 3}, {"A", "B", "C"}}
--> {{1, "A"}, {2, "B"}, {3, "C"}}
An AppleScript list is implemented as a vector array so accessing a list item should have O(1)
efficiency (constant time), the same as a Python list or ObjC NSArray
(both vectors too).
However, there is some dumb implementation in AS that means each lookup also involves incidentally iterating the entire list (IIRC to check for circular containment where a list value has been added to itself, but that’s not important) that brings that efficiency down to O(n)
(linear time); no better than the linked list implementation AS originally had.
Thus, iterating the entire list, which should be O(n)
efficiency, becomes O(n*n)
(quadratic) and drops AS performance in the toilet as soon as lists become large. (And that’s even before we consider most ASers don’t know Computer Science, so will often write/use inefficient algorithms themselves, degrading performance even further.)
What the script object kludge does is tickle AS’s list item access implementation in such a way that it bypasses the pathological iteration, bringing efficiency back to O(1)
. (It’s actually possible to crash AS if you do this in a certain way, but that’s not really important either.)
This WONTFIX stuff is all very tired and all very boring, and none of it is healthy or useful knowledge for programmers or non-programmers. Just one more Stupid that hapless users must wade through cos some developer didn’t have their thinking brain on they day that they wrote it. And one more reason AS needs gracefully retired in favor of a new language that learns from its good aspects (AS looks attractive and “easy” to non-programmers) while learning from all its mistakes and not repeating them as well.