Skip to content

Commit

Permalink
refact: sprint_two_cols definition in terms of sprint_n_cols
Browse files Browse the repository at this point in the history
  • Loading branch information
leovalais committed Nov 26, 2018
1 parent f95bfec commit 9602904
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,10 @@ let sprint_n_cols ?(prefix = "") ?(sep = "\t ") = function
|> String.concat "\n"


let sprint_two_cols ?(prefix = "") ?(sep = "\t ") cols =
let max_len = cols
|> List.map (fun (fstcol, _) -> String.length fstcol)
|> List.fold_left max 0
in
cols
|> List.map (fun (c, c') ->
Printf.sprintf "%s%s%s\t %s"
prefix c
Operators.(" " ^* (max_len - String.length c)) c')
|> String.concat "\n"
let sprint_two_cols ?(prefix = "") ?(sep = "\t ") rows =
rows
|> List.map (fun (c, c') -> [c; c'])
|> sprint_n_cols ~prefix ~sep

let sprint_three_cols ?(prefix = "") ?(sep = "\t ") rows =
rows
Expand Down

0 comments on commit 9602904

Please sign in to comment.