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.159 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.158 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.157 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.156 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.155 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.154 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.153 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.152 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.151 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.150 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.149 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.148 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.147 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.146 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.145 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.144 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.143 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.142 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.141 tracks/ocaml/exercises/hexadecimal/example.ml
trackler-2.2.1.140 tracks/ocaml/exercises/hexadecimal/example.ml