Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/String-length/Mercury/string-length-1.mercury
Normal file
20
Task/String-length/Mercury/string-length-1.mercury
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
:- module string_byte_length.
|
||||
:- interface.
|
||||
|
||||
:- import_module io.
|
||||
|
||||
:- pred main(io::di, io::uo) is det.
|
||||
|
||||
:- implementation.
|
||||
|
||||
:- import_module list, string.
|
||||
|
||||
main(!IO) :-
|
||||
Words = ["møøse", "𝔘𝔫𝔦𝔠𝔬𝔡𝔢", "J\x332\o\x332\s\x332\e\x301\\x332\"],
|
||||
io.write_list(Words, "", write_length, !IO).
|
||||
|
||||
:- pred write_length(string::in, io::di, io::uo) is det.
|
||||
|
||||
write_length(String, !IO):-
|
||||
NumBytes = count_utf8_code_units(String),
|
||||
io.format("%s: %d bytes\n", [s(String), i(NumBytes)], !IO).
|
||||
Loading…
Add table
Add a link
Reference in a new issue