Skip to content

Instantly share code, notes, and snippets.

@prakhar1989
Created July 24, 2014 07:28
Show Gist options
  • Save prakhar1989/b6122865842811d96779 to your computer and use it in GitHub Desktop.
Save prakhar1989/b6122865842811d96779 to your computer and use it in GitHub Desktop.
let max_length header rows =
let lengths list = List.map ~f:String.length list in
List.fold rows
~init: (lengths header)
~f: (fun acc row ->
List.map2_exn ~f:Int.max acc (lengths row))
let make_separator widths =
let pieces = List.map widths
~f:(fun w -> String.make (w + 2) '-') (* padding of 2 chars *)
in
"|" ^ String.concat ~sep:"+" pieces ^ "|"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment