mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
Estimated hours taken: 3
Branches: main
A few handy functions for splitting a string added.
library/string.m:
Added remove_suffix_if_present, split_at_separator, split_at_char,
split_at_string
tests/hard_coded/string_split.m:
A simple test of split_at_* functions.
tests/hard_coded/string_split.exp:
Expected results of the tests of split_at_* functions.
tests/hard_coded/string_various.m:
Created. Added testcase for remove_suffix_if_present.
tests/hard_coded/string_various.exp:
Created. Added results for remove_suffix_if_present.
NEWS:
Added a comment that the functions have been added.
19 lines
431 B
Mathematica
19 lines
431 B
Mathematica
:- module string_various.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module string, char.
|
|
|
|
main(!IO) :-
|
|
io__write_string(remove_suffix_if_present(".gz", "myfile"), !IO),
|
|
io__nl(!IO),
|
|
io__write_string(remove_suffix_if_present(".gz", "myfile.gz"), !IO),
|
|
io__nl(!IO),
|
|
io__write_string(remove_suffix_if_present(".gz", "myfile.gz.gz"), !IO),
|
|
io__nl(!IO),
|
|
true.
|