formatting - Indentation of boxes in Format.fprintf -
please consider function f:
open format let rec f = match | x when x <= 0 -> () | -> pp_open_hovbox std_formatter 2; printf "this line %d@." i; f (i-1); printf "this line %d@." i; close_box (); () it recursively opens hovboxes , prints something, followed newline hint (@.). when call f 3, obtain following output:
this line 3 line 2 line 1 line 1 line 2 line 3 but expected:
this line 3 line 2 line 1 line 1 line 2 line 3 can explain why obtain first output , need change obtain second one?
@. not newline hint, equivalent print_newline calls print_flush closes opened boxes , follows new line.
if want print line line format should open vertical box open_vbox , use print_cut ("@,") whenever want output new line.
Comments
Post a Comment