[m-rev.] diff: add string.is_empty/1
Julien Fischer
jfischer at opturion.com
Thu Feb 12 17:08:21 AEDT 2015
Add string.is_empty/1.
library/string.m:
Add the test predicate is_empty/1 for strings.
This is useful when working with higher-order code.
NEWS:
Announce the above addition.
Unrelated change:
s/terminating newline character/terminating newline/
since a newline may be composed of multiple characters.
Julien.
diff --git a/NEWS b/NEWS
index 9e29c31..d3e35d8 100644
--- a/NEWS
+++ b/NEWS
@@ -32,7 +32,7 @@ Changes to the Mercury standard library:
* We have added the print_line and write_line family of predicates to the
io module. These behave like the print and write predicates, but also
- write a terminating newline character.
+ write a terminating newline.
* io.print and string_writer.print now print arbitrary precision integers
in their decimal form instead of printing their underlying representation.
@@ -105,9 +105,10 @@ Changes to the Mercury standard library:
- error/2
- func_error/2
-* The following predicate has been added to the string module:
+* The following predicates have been added to the string module:
- is_all_alnum/1
+ - is_empty/1
* The following predicates have been added to the map module:
diff --git a/library/string.m b/library/string.m
index 8a57d7b..9283b2b 100644
--- a/library/string.m
+++ b/library/string.m
@@ -396,6 +396,9 @@
%
% Tests on strings.
%
+ % True if string is the empty string.
+ %
+:- pred is_empty(string::in) is semidet.
% True if string contains only alphabetic characters [A-Za-z].
%
@@ -2746,6 +2749,8 @@ string.hash6_loop(String, Index, Length, !HashVal) :-
% For speed, most of these predicates have C versions as well as
% Mercury versions. XXX why not all?
+is_empty("").
+
:- pragma foreign_proc("C",
is_all_alpha(S::in),
[will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail,
More information about the reviews
mailing list