Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 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).
|
||||
20
Task/String-length/Mercury/string-length-2.mercury
Normal file
20
Task/String-length/Mercury/string-length-2.mercury
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
:- module string_character_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) :-
|
||||
NumChars = count_codepoints(String),
|
||||
io.format("%s: %d characters\n", [s(String), i(NumChars)], !IO).
|
||||
Loading…
Add table
Add a link
Reference in a new issue