Sha256: 13194dc9314769e1ba93a411810dd446b3b53f67ce5ab7f95283001eabb04b6a

Contents?: true

Size: 433 Bytes

Versions: 68

Compression:

Stored size: 433 Bytes

Contents

open Base

let digit_to_int c =
  match c with
  | '0'..'9'  -> Some (Char.to_int(c) - 48)
  | 'a'..'f'  -> Some (Char.to_int(c) - 97 + 10)
  | 'A'..'F'  -> Some (Char.to_int(c) - 97 + 10)
  | _ -> None

let to_int hex_str =
  let rec go acc = function
    | []    -> acc
    | c::cs -> match digit_to_int c with
                    | Some n -> go (acc * 16 + n) cs
                    | None -> 0 in
  go 0 (String.to_list hex_str)

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.138 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.137 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.136 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.135 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.134 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.133 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.132 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.131 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.130 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.129 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.128 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.127 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.126 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.125 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.124 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.123 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.122 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.121 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.120 tracks/ocaml/exercises/hexadecimal/example.ml