Source file quick_print.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
(** [strings_list ~prefix list] prints the [list] of strings to the standard output with the [prefix]. *)
let strings_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%s" item in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [string_list_list ?prefix list] prints a list of string lists to standard output.
Each inner list is formatted as a bracketed, semicolon-separated sequence of strings (e.g., "[one; two; three]").
The inner lists themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list.*)
let string_list_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%s" item in
let pp_list_inner fmt inner_list =
Format.fprintf fmt "[";
Format.pp_print_list ~pp_sep pp_item_inner fmt inner_list;
Format.fprintf fmt "]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_list_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [string_array_list ?prefix list] prints a list of string arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of strings
enclosed by array brackets (e.g., "[|one; two; three|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list. *)
let string_array_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%s" item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [string_array_array ?prefix arr] prints an array of string arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of strings
enclosed by array brackets (e.g., "[|one; two; three|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the array. *)
let string_array_array ?(prefix = "") arr =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%s" item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter (Array.to_list arr);
Format.fprintf Format.std_formatter "]\n"
(** [chars_list ~prefix list] prints the [list] of chars to the standard output with the [prefix]. *)
let chars_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%c" item in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [char_list_list ?prefix list] prints a list of char lists to standard output.
Each inner list is formatted as a bracketed, semicolon-separated sequence of characters (e.g., "[a; b; c]").
The inner lists themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list. *)
let char_list_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%c" item in
let pp_list_inner fmt inner_list =
Format.fprintf fmt "[";
Format.pp_print_list ~pp_sep pp_item_inner fmt inner_list;
Format.fprintf fmt "]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_list_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [char_array_list ?prefix list] prints a list of character arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of characters
enclosed by array brackets (e.g., "[|'a'; 'b'; 'c'|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list. *)
let char_array_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "'%c'" item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [char_array_array ?prefix arr] prints an array of char arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of chars
enclosed by array brackets (e.g., "[|a; b; c|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the array. *)
let char_array_array ?(prefix = "") arr =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%c" item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[|" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter (Array.to_list arr);
Format.fprintf Format.std_formatter "|]\n"
(** [int_list ~prefix list] prints the [list] of integers to the standard output with the [prefix]. *)
let int_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%d" item in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [int_list_list ?prefix list] prints a list of int lists to standard output.
Each inner list is formatted as a bracketed, semicolon-separated sequence of integers (e.g., "[1; 2; 3]").
The inner lists themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list. *)
let int_list_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%d" item in
let pp_list_inner fmt inner_list =
Format.fprintf fmt "[";
Format.pp_print_list ~pp_sep pp_item_inner fmt inner_list;
Format.fprintf fmt "]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_list_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [int_array_list ?prefix list] prints a list of integer arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of integers
enclosed by array brackets (e.g., "[|1; 2; 3|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list. *)
let int_array_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%d" item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [int_array_array ?prefix arr] prints an array of integer arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of integers
enclosed by array brackets (e.g., "[|1; 2; 3|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the array. *)
let int_array_array ?(prefix = "") arr =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%d" item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter (Array.to_list arr);
Format.fprintf Format.std_formatter "]\n"
(** [float_list ~prefix ~precision list] prints the [list] of floats to the standard output with
a given [precision] and with the [prefix]. *)
let float_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "@[<v 0>%.*f@]" precision item in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [float_list_list ?prefix ?precision list] prints a list of float lists to standard output.
Each inner list is formatted as a bracketed, semicolon-separated sequence of floats (e.g., "[1.23; 4.56; 7.89]"),
with [precision] decimal places.
The inner lists themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) specifies the number of decimal places for the floating-point values. *)
let float_list_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%.*f" precision item in
let pp_list_inner fmt inner_list =
Format.fprintf fmt "[";
Format.pp_print_list ~pp_sep pp_item_inner fmt inner_list;
Format.fprintf fmt "]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_list_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [float_array_list ?prefix ?precision list] prints a list of float arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of floats
enclosed by array brackets (e.g., "[|1.00; 2.00; 3.00|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2, if omitted) determines the number of decimal places for each float. *)
let float_array_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "%.*f" precision item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [float_array_array ?prefix ?precision arr] prints an array of float arrays to standard output.
Each inner array is formatted as a bracketed, semicolon-separated sequence of floats
enclosed by array brackets (e.g., "[|1.00; 2.00; 3.00|]").
The inner arrays themselves are also separated by semicolons and spaces.
The optional [prefix] argument (defaulting to an empty string, if omitted) is printed before the array.
The optional [precision] argument specifies the number of decimal places for the floats (defaulting to 2 if omitted). *)
let float_array_array ?(prefix = "") ?(precision = 2) arr =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item_inner fmt item = Format.fprintf fmt "@[<v 0>%.*f@]" precision item in
let pp_array_inner fmt inner_array =
Format.fprintf fmt "[|";
Format.pp_print_list ~pp_sep pp_item_inner fmt (Array.to_list inner_array);
Format.fprintf fmt "|]"
in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_array_inner Format.std_formatter (Array.to_list arr);
Format.fprintf Format.std_formatter "]\n"
(** [string_string_tuple_list ?prefix list] prints a list of [(string, string)] tuples to standard output.
Each tuple is formatted as [(string1, string2)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let string_string_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%s, %s)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [string_char_tuple_list ?prefix list] prints a list of [(string, char)] tuples to standard output.
Each tuple is formatted as [(string, c)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let string_char_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%s, %c)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [string_int_tuple_list ?prefix list] prints a list of [(string, int)] tuples to standard output.
Each tuple is formatted as [(string, n)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let string_int_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%s, %d)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [string_float_tuple_list ?prefix ?precision list] prints a list of [(string, float)] tuples to standard output.
Each tuple is formatted as [(string, f)], where [f] has [precision] decimal places.
Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) sets the number of decimal places for floats. *)
let string_float_tuple_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%s, %.*f)" a precision b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [char_string_tuple_list ?prefix list] prints a list of [(char, string)] tuples to standard output.
Each tuple is formatted as [(c, string)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let char_string_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%c, %s)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [char_char_tuple_list ?prefix list] prints a list of [(char, char)] tuples to standard output.
Each tuple is formatted as [(c1, c2)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let char_char_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%c, %c)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [char_int_tuple_list ?prefix list] prints a list of [(char, int)] tuples to standard output.
Each tuple is formatted as [(c, n)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let char_int_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%c, %d)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [char_float_tuple_list ?prefix ?precision list] prints a list of [(char, float)] tuples on standard output.
Each tuple is formatted as [(c, f.##)], where f has [precision] decimal places. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) will be printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) sets the number of decimal places for floats. *)
let char_float_tuple_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%c, %.*f)" a precision b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [int_string_tuple_list ?prefix list] prints a list of [(int, string)] tuples to standard output.
Each tuple is formatted as [(n, string)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let int_string_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%d, %s)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [int_char_tuple_list ?prefix list] prints a list of [(int, char)] tuples to standard output.
Each tuple is formatted as [(n, c)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let int_char_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%d, %c)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [int_int_tuple_list ?prefix list] prints a list of [(int, int)] tuples to standard output.
Each tuple is formatted as [(n, m)]. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list. *)
let int_int_tuple_list ?(prefix = "") list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%d, %d)" a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [int_float_tuple_list ?prefix ?precision list] prints a list of [(int, float)] tuples to standard output.
Each tuple is formatted as [(n, f)], where [f] is a float with [precision] decimal places. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) sets the number of decimal places for float. *)
let int_float_tuple_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%d, %.*f)" a precision b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [float_string_tuple_list ?prefix ?precision list] prints a list of [(float, string)] tuples to standard output.
Each tuple is formatted as [(f, string)], where [f] is a float with [precision] decimal places. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) sets the number of decimal places for the float. *)
let float_string_tuple_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%.*f, %s)" precision a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [float_char_tuple_list ?prefix ?precision list] prints a list of [(float, char)] tuples to standard output.
Each tuple is formatted as [(f, c)], where [f] is a float with [precision] decimal places. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) sets the number of decimal places for the float. *)
let float_char_tuple_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%.*f, %c)" precision a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [float_int_tuple_list ?prefix ?precision list] prints a list of [(float, int)] tuples to standard output.
Each tuple is formatted as [(f, n)], where [f] is a float with [precision] decimal places. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) sets the number of decimal places for the float. *)
let float_int_tuple_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%.*f, %d)" precision a b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [float_float_tuple_list ?prefix ?precision list] prints a list of [(float, float)] tuples to standard output.
Each tuple is formatted as [(f1, f2)], where [f1] and [f2] are floats with [precision] decimal places. Tuples are separated by a semicolon and a space.
The optional [prefix] argument (defaulting to an empty string if omitted) is printed before the list.
The optional [precision] argument (defaulting to 2 if omitted) sets the number of decimal places for the floats. *)
let float_float_tuple_list ?(prefix = "") ?(precision = 2) list =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (a, b) = Format.fprintf fmt "(%.*f, %.*f)" precision a precision b in
Format.fprintf Format.std_formatter "%s[" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list;
Format.fprintf Format.std_formatter "]\n"
(** [strings_array ~prefix arr] converts the [arr] array to a list and prints it
to the standard output with a given [prefix]. *)
let strings_array ?(prefix = "") arr =
let as_list = Array.to_list arr in
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%s" item in
Format.fprintf Format.std_formatter "%s[|" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter as_list;
Format.fprintf Format.std_formatter "|]\n"
(** [chars_array ~prefix arr] converts the [arr] array of characters to a list and prints it
to the standard output with a given [prefix]. *)
let chars_array ?(prefix = "") arr =
let as_list = Array.to_list arr in
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%c" item in
Format.fprintf Format.std_formatter "%s[|" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter as_list;
Format.fprintf Format.std_formatter "|]\n"
(** [int_array ~prefix arr] converts the [arr] array of integers to a list and prints it
to the standard output with a given [prefix]. *)
let int_array ?(prefix = "") arr =
let as_list = Array.to_list arr in
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%d" item in
Format.fprintf Format.std_formatter "%s[|" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter as_list;
Format.fprintf Format.std_formatter "|]\n"
(** [float_array ~prefix ~precision arr] converts the [arr] array of floats to a list and prints it
with the specified [precision] and [prefix] to the standard output. *)
let float_array ?(prefix = "") ?(precision = 2) arr =
let as_list = Array.to_list arr in
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "@[<v 0>%.*f@]" precision item in
Format.fprintf Format.std_formatter "%s[|" prefix;
Format.pp_print_list ~pp_sep pp_item Format.std_formatter as_list;
Format.fprintf Format.std_formatter "|]\n"
(** [hashtable_int_string ~prefix ht] prints the entries of a hashtable [ht] (with integer keys and string values)
to the standard output, using the [prefix].
Each entry is represented as a tuple (key, value). *)
let hashtable_int_string ?(prefix = "") ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%d, %s)" k v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_int_char ~prefix ht] prints the entries of a hashtable [ht] (with integer keys and character values)
to the standard output, using the [prefix].
Each entry is represented as a tuple (key, value). *)
let hashtable_int_char ?(prefix = "") ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%d, %c)" k v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_int_int ~prefix ht] prints the entries of a hashtable [ht] (with integer keys and integer values)
to the standard output, using the [prefix].
Each entry is represented as a tuple (key, value). *)
let hashtable_int_int ?(prefix = "") ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%d, %d)" k v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_int_float ~prefix ~precision ht] prints the entries of a hashtable [ht] (with integer keys and floating point values)
to the standard output, using the [prefix]. The floating point values are shown with the given [precision].
Each entry is represented as a tuple (key, value). *)
let hashtable_int_float ?(prefix = "") ?(precision = 2) ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%d, %.*f)" k precision v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_string_string ~prefix ht] prints the entries of a hashtable [ht] (with string keys and string values)
to the standard output, using the [prefix].
Each entry is represented as a tuple (key, value). *)
let hashtable_string_string ?(prefix = "") ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%s, %s)" k v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_string_char ~prefix ht] prints the entries of a hashtable [ht] (with string keys and character values)
to the standard output, using the [prefix].
Each entry is represented as a tuple (key, value). *)
let hashtable_string_char ?(prefix = "") ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%s, %c)" k v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_int_int ~prefix ht] prints the entries of a hashtable [ht] (with string keys and integer values)
to the standard output, using the [prefix].
Each entry is represented as a tuple (key, value). *)
let hashtable_string_int ?(prefix = "") ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%s, %d)" k v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_int_float ~prefix ~precision ht] prints the entries of a hashtable [ht] (with string keys and floating point values)
to the standard output, using the [prefix]. The floating point values are shown with the given [precision].
Each entry is represented as a tuple (key, value). *)
let hashtable_string_float ?(prefix = "") ?(precision = 2) ht =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt (k, v) = Format.fprintf fmt "(%s, %.*f)" k precision v in
Format.fprintf Format.std_formatter "%s{" prefix;
Hashtbl.iter
(fun k v ->
Format.fprintf Format.std_formatter "%a" pp_item (k, v);
pp_sep Format.std_formatter ())
ht;
Format.fprintf Format.std_formatter "}\n"
(** [hashtable_int_string_list ~prefix ht] prints the entries of a hashtable [ht] (with integer keys and list of strings)
to the standard output, using the [prefix].
The strings in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_int_string_list ?(prefix = "") ht =
let str_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " list in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let str_list = str_list_to_str v in
Printf.printf "(%d, %s); " k str_list)
ht;
print_endline "}"
(** [hashtable_int_char_list ~prefix ht] prints the entries from the hashtable [ht] (with integer keys and list of chars)
to the standard output, using the [prefix].
The characters in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_int_char_list ?(prefix = "") ht =
let char_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " (List.map Char.escaped list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let char_list = char_list_to_str v in
Printf.printf "(%d, %s); " k char_list)
ht;
print_endline "}"
(** [hashtable_int_int_list ~prefix ht] prints the entries of hashtable [ht] (with integer keys and list of integers)
to the standard output, using the [prefix].
The integers in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_int_int_list ?(prefix = "") ht =
let int_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " (List.map string_of_int list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let int_list = int_list_to_str v in
Printf.printf "(%d, %s); " k int_list)
ht;
print_endline "}"
(** [hashtable_int_float_list ~prefix ~precision ht] prints the entries of the hashtable [ht] (with integer keys and list of floats)
to the standard output, using the [prefix]. Floating point numbers are formatted with the provided [precision].
The floats in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_int_float_list ?(prefix = "") ?(precision = 2) ht =
let float_list_to_str ?(prefix = "") ?(precision = 2) list =
let float_to_str f = Printf.sprintf "%.*f" precision f in
let s = prefix ^ String.concat "; " (List.map float_to_str list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let float_list = float_list_to_str ~precision v in
Printf.printf "(%d, %s); " k float_list)
ht;
print_endline "}"
(** [hashtable_string_string_list ~prefix ht] prints the entries of a hashtable [ht] (with string keys and list of strings)
to the standard output, using the [prefix].
The strings in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_string_string_list ?(prefix = "") ht =
let str_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " list in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let str_list = str_list_to_str v in
Printf.printf "(%s, %s); " k str_list)
ht;
print_endline "}"
(** [hashtable_string_char_list ~prefix ht] prints the entries from the hashtable [ht] (with string keys and list of chars)
to the standard output, using the [prefix].
The characters in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_string_char_list ?(prefix = "") ht =
let char_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " (List.map Char.escaped list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let char_list = char_list_to_str v in
Printf.printf "(%s, %s); " k char_list)
ht;
print_endline "}"
(** [hashtable_string_int_list ~prefix ht] prints the entries of hashtable [ht] (with string keys and list of integers)
to the standard output, using the [prefix].
The integers in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_string_int_list ?(prefix = "") ht =
let int_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " (List.map string_of_int list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let int_list = int_list_to_str v in
Printf.printf "(%s, %s); " k int_list)
ht;
print_endline "}"
(** [hashtable_string_float_list ~prefix ~precision ht] prints the entries of the hashtable [ht] (with string keys and list of floats)
to the standard output, using the [prefix]. Floating point numbers are formatted with the provided [precision].
The floats in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_string_float_list ?(prefix = "") ?(precision = 2) ht =
let float_list_to_str ?(prefix = "") ?(precision = 2) list =
let float_to_str f = Printf.sprintf "%.*f" precision f in
let s = prefix ^ String.concat "; " (List.map float_to_str list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let float_list = float_list_to_str ~precision v in
Printf.printf "(%s, %s); " k float_list)
ht;
print_endline "}"
(** [hashtable_char_string_list ~prefix ht] prints the entries of a hashtable [ht] (with character keys and list of strings)
to the standard output, using the [prefix].
The strings in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_char_string_list ?(prefix = "") ht =
let str_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " list in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let str_list = str_list_to_str v in
Printf.printf "(%c, %s); " k str_list)
ht;
print_endline "}"
(** [hashtable_char_char_list ~prefix ht] prints the entries from the hashtable [ht] (with char keys and list of chars)
to the standard output, using the [prefix].
The characters in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_char_char_list ?(prefix = "") ht =
let char_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " (List.map Char.escaped list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let char_list = char_list_to_str v in
Printf.printf "(%c, %s); " k char_list)
ht;
print_endline "}"
(** [hashtable_char_int_list ~prefix ht] prints the entries of hashtable [ht] (with character keys and list of integers)
to the standard output, using the [prefix].
The integers in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_char_int_list ?(prefix = "") ht =
let int_list_to_str ?(prefix = "") list =
let s = prefix ^ String.concat "; " (List.map string_of_int list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let int_list = int_list_to_str v in
Printf.printf "(%c, %s); " k int_list)
ht;
print_endline "}"
(** [hashtable_char_float_list ~prefix ~precision ht] prints the entries of the hashtable [ht] (with character keys and list of floats)
to the standard output, using the [prefix]. Floating point numbers are formatted with the provided [precision].
The floats in each list are joined with '; ' and enclosed in brackets []. *)
let hashtable_char_float_list ?(prefix = "") ?(precision = 2) ht =
let float_list_to_str ?(prefix = "") ?(precision = 2) list =
let float_to_str f = Printf.sprintf "%.*f" precision f in
let s = prefix ^ String.concat "; " (List.map float_to_str list) in
Printf.sprintf "[%s]" s
in
print_string (prefix ^ "{");
Hashtbl.iter
(fun k v ->
let float_list = float_list_to_str ~precision v in
Printf.printf "(%c, %s); " k float_list)
ht;
print_endline "}"
(** [tuple_strings_list_strings_list ?prefix (list1, list2)]
prints the tuple of string lists [(list1, list2)] to the standard output. Each string from the lists is separated by a semicolon and a space "; ".
The tuple is presented in this string format: "([list1], [list2])". *)
let tuple_strings_list_strings_list ?(prefix = "") (list1, list2) =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%s" item in
Format.fprintf Format.std_formatter "%s(" prefix;
Format.fprintf Format.std_formatter "[";
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list1;
Format.fprintf Format.std_formatter "], [";
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list2;
Format.fprintf Format.std_formatter "]";
Format.fprintf Format.std_formatter ")\n"
(** [tuple_chars_list_chars_list ?prefix (list1, list2)]
prints optional [prefix] and the tuple of character lists [(list1, list2)] to the standard output, with each character separated by a semicolon and a space "; ".
The tuple is presented in this string format: "([list1], [list2])". *)
let tuple_chars_list_chars_list ?(prefix = "") (list1, list2) =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "'%c'" item in
Format.fprintf Format.std_formatter "%s(" prefix;
Format.fprintf Format.std_formatter "[";
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list1;
Format.fprintf Format.std_formatter "], [";
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list2;
Format.fprintf Format.std_formatter "]";
Format.fprintf Format.std_formatter ")\n"
(** [tuple_ints_list_ints_list ?prefix (list1, list2)]
prints optional [prefix] and the tuple of integer lists [(list1, list2)] to the standard output, with each integer separated by a semicolon and a space "; ".
The tuple is presented in this string format: "([list1], [list2])". *)
let tuple_ints_list_ints_list ?(prefix = "") (list1, list2) =
let pp_sep fmt () = Format.fprintf fmt "; " in
let pp_item fmt item = Format.fprintf fmt "%d" item in
Format.fprintf Format.std_formatter "%s(" prefix;
Format.fprintf Format.std_formatter "[";
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list1;
Format.fprintf Format.std_formatter "], [";
Format.pp_print_list ~pp_sep pp_item Format.std_formatter list2;
Format.fprintf Format.std_formatter "]";
Format.fprintf Format.std_formatter ")\n"
(** [tuple_floats_list_floats_list ?prefix ?precision (list1, list2)]
prints the optional [prefix] and the tuple of float lists [(list1, list2)] as a formatted string with each number separated by a semicolon and a space "; ".
The [precision] parameter defines how many decimal places each float should have, defaulting to 2.
The tuple is presented in this stri ng format: "([list1], [list2])". *)
let tuple_floats_list_floats_list ?(prefix = "") ?(precision = 2) (list1, list2) =
let float_list_to_str list =
let float_to_str f = Printf.sprintf "%.*f" precision f in
let s = "[" ^ String.concat "; " (List.map float_to_str list) ^ "]" in
s
in
let float_list1 = float_list_to_str list1 in
let float_list2 = float_list_to_str list2 in
Printf.printf "%s(%s, %s)\n" prefix float_list1 float_list2