mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
Branches: main Deprecate string.substring, string.foldl_substring, etc. in favour of new procedures named string.between, string.foldl_between, etc. The "between" procedures take a pair of [Start, End) endpoints instead of Start, Count arguments. The reasons for this change are: - the "between" procedures are more convenient - "between" should be unambiguous. You can guess that it takes an End argument instead of a Count argument without looking up the manual. - Count arguments necessarily counted code units, but when working with non-ASCII strings, almost the only way that the values would be arrived at is by substracting one end point from another. - it paves the way for a potential change to replace string offsets with an abstract type. We cannot do that if users regularly have to perform a subtraction between two offsets. library/string.m: Add string.foldl_between, string.foldl2_between, string.foldr_between, string.between. Deprecate the old substring names. Replace string.substring_by_codepoint by string.between_codepoints. compiler/elds_to_erlang.m: compiler/error_util.m: compiler/rbmm.live_variable_analysis.m: compiler/timestamp.m: extras/posix/samples/mdprof_cgid.m: library/bitmap.m: library/integer.m: library/lexer.m: library/parsing_utils.m: mdbcomp/trace_counts.m: profiler/demangle.m: Conform to changes. tests/general/Mercury.options: tests/general/string_foldl_substring.exp: tests/general/string_foldl_substring.m: tests/general/string_foldr_substring.exp: tests/general/string_foldr_substring.m: tests/hard_coded/Mercury.options: tests/hard_coded/string_substring.m: Test both between and substring procedures. tests/hard_coded/string_codepoint.exp: tests/hard_coded/string_codepoint.exp2: tests/hard_coded/string_codepoint.m: Update names in test outputs. NEWS: Announce the change.
17 lines
673 B
Plaintext
17 lines
673 B
Plaintext
rev("Hello, World!", 0, 5) = "olleH"
|
|
rev("Hello, World!", 0, 50) = "!dlroW ,olleH"
|
|
rev("Hello, World!", 0, -5) = ""
|
|
rev("Hello, World!", -5, 12) = "dlroW ,olleH"
|
|
rev("Hello, World!", -5, 50) = "!dlroW ,olleH"
|
|
rev("Hello, World!", 7, 0) = ""
|
|
rev("Hello, World!", 7, 12) = "dlroW"
|
|
rev("Hello, World!", 50, 10) = ""
|
|
rev_old("Hello, World!", 0, 5) = "olleH"
|
|
rev_old("Hello, World!", 0, 50) = "!dlroW ,olleH"
|
|
rev_old("Hello, World!", 0, -5) = ""
|
|
rev_old("Hello, World!", -5, 12) = "dlroW ,olleH"
|
|
rev_old("Hello, World!", -5, 50) = "!dlroW ,olleH"
|
|
rev_old("Hello, World!", 7, 0) = ""
|
|
rev_old("Hello, World!", 7, 12) = "!dlroW"
|
|
rev_old("Hello, World!", 50, 10) = ""
|