Created
July 24, 2014 07:28
-
-
Save prakhar1989/b6122865842811d96779 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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