File: supported_version.ml

package info (click to toggle)
ppxlib 0.37.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,804 kB
  • sloc: ml: 66,587; sh: 103; makefile: 40; python: 36
file content (26 lines) | stat: -rw-r--r-- 442 bytes parent folder | download
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
type t = int * int

let all =
  [
    (4, 08);
    (4, 09);
    (4, 10);
    (4, 11);
    (4, 12);
    (4, 13);
    (4, 14);
    (5, 0);
    (5, 1);
    (5, 2);
    (5, 3);
    (5, 4);
  ]

let to_string (a, b) =
  if a < 5 then Printf.sprintf "%d.%02d" a b else Printf.sprintf "%d.%d" a b

let to_int (a, b) = (a * 100) + b

let of_string s =
  let t = Scanf.sscanf s "%u.%u" (fun a b -> (a, b)) in
  if List.mem t all then Some t else None