Given a list of tuples, where each tuple consists of 3 integers, transpose the list recursively so that the "rows" and "columns" are swapped. The result will be a list of lists.
So for example:transpose [ (1, 2, 3); (11, 12, 13) ]=> [ [1; 11]; [2; 12]; [3; 13] ]
So I tried:
let rec transpose LT = match LT with | [] -> [[], [], []] | (a, b, c) :: tail -> let rest = transpose tail match rest with | [d; e; f] -> [a::d; b::e; c::f]
but is getting the error:
All elements of a list must be implicitly convertible to the type ofthe first element, which here is ''a list * 'b list * 'c list'. Thiselement has type ''d list'.
at the list of lists [a::d; b::e; c::f]
Can anyone tell me what I'm missing or what I'm doing wrong?