[m-rev.] Minor addition to string.m
Ralph Becket
rafe at cs.mu.OZ.AU
Wed Jan 29 14:56:01 AEDT 2003
Estimated hours taken: 0.5
Branches: main
library/string.m:
Added function chomp/1.
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.190
diff -u -r1.190 string.m
--- library/string.m 29 Nov 2002 13:25:56 -0000 1.190
+++ library/string.m 29 Jan 2003 03:53:26 -0000
@@ -274,6 +274,9 @@
% may be linear in the length of the string.
% Use with care!
+:- func string__chomp(string) = string.
+% string__chomp(String) is String minus a trailing "\n", if any.
+
:- pred string__set_char(char, int, string, string).
:- mode string__set_char(in, in, in, out) is semidet.
% XXX This mode is disabled because the compiler puts constant
@@ -3798,6 +3801,13 @@
N = N0
else
error("string__det_base_string_to_int/2: conversion failed")
+ ).
+
+%-----------------------------------------------------------------------------%
+
+string__chomp(S) =
+ ( if string__suffix(S, "\n") then string__left(S, length(S) - 1)
+ else S
).
%------------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list