-- transpose :: [[a]] -> [[a]] on transpose(xss) script column on lambda(_, iCol) script row on lambda(xs) item iCol of xs end lambda end script map(row, xss) end lambda end script map(column, item 1 of xss) end transpose -- TEST on run transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) --> {{1, 4, 7, 10}, {2, 5, 8, 11}, {3, 6, 9, 12}} end run -- GENERIC LIBRARY FUNCTIONS -- map :: (a -> b) -> [a] -> [b] on map(f, xs) tell mReturn(f) set lng to length of xs set lst to {} repeat with i from 1 to lng set end of lst to lambda(item i of xs, i, xs) end repeat return lst end tell end map -- Lift 2nd class handler function into 1st class script wrapper -- mReturn :: Handler -> Script on mReturn(f) if class of f is script then f else script property lambda : f end script end if end mReturn