Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
11
Task/String-length/OCaml/string-length-3.ml
Normal file
11
Task/String-length/OCaml/string-length-3.ml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
let utf8_length (s: String.t) =
|
||||
let byte_length = String.length s in
|
||||
let rec count acc n =
|
||||
if n = byte_length
|
||||
then acc
|
||||
else
|
||||
let n' = n + (String.get_utf_8_uchar s n |> Uchar.utf_decode_length) in
|
||||
count (succ acc) n'
|
||||
in
|
||||
count 0 0
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue