content: -- TRANSPOSE -----------------------------------------------------------------
  
  -- transpose :: [[a]] -> [[a]]
  on transpose(xss)
      script column
          on |λ|(_, iCol)
              script row
                  on |λ|(xs)
                      item iCol of xs
                  end |λ|
              end script
  
              map(row, xss)
          end |λ|
      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 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 |λ|(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 |λ| : f
          end script
      end if
  end mReturn
  