let column m i = if Array.for_all ~f:(fun row -> i < Array.length row) m then Array.init (Array.length m) (fun j -> m.(j).(i)) else failwith (sprintf "invalid column index %d" i)