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.180 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.179 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.178 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.177 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.176 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.175 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.174 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.173 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.172 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.171 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.170 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.169 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.167 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.166 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.165 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.164 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.163 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.162 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.161 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.160 tracks/ocaml/exercises/hexadecimal/example.ml