printf - OCaml: Print a long int list 10 elements per row -


i'm working long lists of integers , need way of printing them 10 row. i've got far , i'm stuck:

open printf     let print_list list = list.iter (printf "%d ") list;;  (* remove first n elements list *) let rec remove n list =  if n== 0 list else match list | [] -> [] | hd::tl -> remove (n-1) tl;;  (* remove , return first n elements list  *) let rec take n list =  match n  | 0 -> [] | _ -> list.hd list :: take (n-1) (list.tl list);;  let rec print_rows list =      if list.length list > 10         begin             let l = take 10 list;             print_list l;             print_endline " ";             print_rows (remove 5 list)         end else print_list list;; 

i'm sure there better way recursively matching patterns, can't figure out. help!

here's function close want. doesn't fancy, counts number of ints printed far , inserts endlines @ right times.

let printby10 intlist =     let iprint count n =         printf.printf "%d " n;         if count mod 10 = 9 printf.printf "\n";         count + 1     in     ignore (list.fold_left iprint 0 intlist) 

this code leaves incomplete line if number of ints isn't multiple of 10. maybe want fix up.