diff options
| author | Jon French | 2018-04-30 15:18:56 +0100 |
|---|---|---|
| committer | Jon French | 2018-05-01 16:58:26 +0100 |
| commit | f8abc90f5e7ae8e25f2750a186eee2ef30021cf5 (patch) | |
| tree | 907ab7b81234f4bcf5cdede79c6a96e0cccb3edd /src/sail_lib.ml | |
| parent | 274204a6f36d7c62a2030ed72f47d07f60c23a34 (diff) | |
further progress but confounds the type checker?
Diffstat (limited to 'src/sail_lib.ml')
| -rw-r--r-- | src/sail_lib.ml | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/sail_lib.ml b/src/sail_lib.ml index 188a0703..e1a3c81f 100644 --- a/src/sail_lib.ml +++ b/src/sail_lib.ml @@ -469,6 +469,15 @@ let string_length str = Big_int.of_int (String.length str) let string_append (s1, s2) = s1 ^ s2 +(* highly inefficient recursive implementation *) +let rec maybe_int_of_prefix = function + | "" -> None + | str -> + let len = String.length str in + match int_of_string_opt str with + | Some n -> Some (Big_int.of_int n, Big_int.of_int len) + | None -> maybe_int_of_prefix (String.sub str 0 (len - 1)) + let lt_int (x, y) = Big_int.less x y let set_slice (out_len, slice_len, out, n, slice) = |
