I have a working Haskell example of how to do it when we want to add zeros to the left and to the right of a list as two separate functions, and I did it because I considered the possibility of safe transposition by using a different definition for the latter, which I will post here as well to ask whether or not it's important to have such concerns.
rectangular :: [[Integer]] -> [[Integer]]
rectangular m = rect m []
where
rect [] a = ([0]:a)
rect (l:[]) a = (l:a)
rect (l:j:ks) a
| length l < length j = rect ((0:l):(rect (j:ks) a)) a
| length l > length j = rect (l:(rect ((0:j):ks) a)) a
| otherwise = rect (l:a) (rect (j:ks) a)
The above is to add zeros to the left, so it should be obvious how to add to the right, and the transposition definition that I'm using for this is:
transposition :: [[a]] -> [[a]]
transposition m = transpose' m []
where
transpose' [] a = a
transpose' ([]:xss) a = transpose' xss a
transpose' ((x:xs):xss) a = transpose' a ((x:map head xss): transpose' (xs:map tail xss) a)
Now that the list of lists is rectangular, transposition should work without running into empty list calls, before it's run to the end with every row having the same number of columns. Is this useful or simply redundant? These are numbers, when it could be data, so should we run the risk of adding to it? That is, in case we redefined it to accept other types, or generalized the choice between left and right.