[m-rev.] for review: string__join_list in C#

Yoann Dubreuil ydu at miscrit.be
Thu Sep 6 20:34:06 AEST 2001


Hi,


===================================================================


Estimated hours taken: 1
User: ydu
Branches: main

library/string.m:
	Implementation of string__join_list in C#

Index: string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.157
diff -u -r1.157 string.m
--- string.m	4 Sep 2001 15:12:23 -0000	1.157
+++ string.m	6 Sep 2001 10:25:48 -0000
@@ -1041,10 +1041,21 @@
 	).
 
 :- pragma foreign_proc("C#",
-		string__join_list(_Sep::in, _Strs::in) = (_Str::uo),
-		[will_not_call_mercury, thread_safe], "{
-	mercury.runtime.Errors.SORRY(""foreign code for this function"");
-	_Str = null;
+		string__join_list(Sep::in, Strs::in) = (Str::uo),
+		[will_not_call_mercury, thread_safe], "
+{	
+	System.Text.StringBuilder tmpStr = new System.Text.StringBuilder();
+
+	while(mercury.runtime.LowLevelData.list_is_cons(Strs)) {
+		tmpStr.Append(mercury.runtime.LowLevelData.list_get_head(Strs));
+		Strs = mercury.runtime.LowLevelData.list_get_tail(Strs);
+
+		if (mercury.runtime.LowLevelData.list_is_cons(Strs)) {
+			tmpStr.Append(Sep);
+		}
+	}
+
+	Str = tmpStr.ToString();
 }").
 
 %-----------------------------------------------------------------------------%


--------------------------------------------------------------------------
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