this type of construction is wrong (imo)
If you really want to have code sharing here, you should build a function that writes out a list when you now the length.
then use it with let n = (List.length list) in output_x  n list 
and let (n,list) = cl in output_x n list