[m-users.] Possiblt stupid list question....

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Dec 22 03:36:08 AEDT 2021



On Tue, 21 Dec 2021 16:21:06 +0000, "Sean Charles (emacstheviking)" <objitsu at gmail.com> wrote:

> If I have a list of strings I can use
> 
> 	string.join_list(Separator, Strings)
> 
> but if I have a list of things, and I want to separate them all with a list of another thing within the same type…?
> 
> I have a formatted output system, it encapsulates text in various type constructors
> 
> 	t(string)
> 	tnl(string)
> 	etc
> 
> so given a list
> 
> 	[ t(“arg1”), t(“arg2”) ]
> 
> how do I arrive at
> 
> 	[ t(“arg1”), t(“, “), t(“arg2”) ]

There is no predicate or function in the Mercury standard library
that does this. On the other hand, there are several different versions
of it in the error message formatting module of the compiler,
error_util.m, that all do slightly different versions of this job.
Some generate output such as "1, 2, 3" (just putting ", " between
successive integers), while others treat the gap between the
last pair of elements differently, generating output such as
"1, 2 and 3".

> I COULD introduce a new type constructor called csv() but …. just asking for a friend etc.

I don't understand how a new type constructor would help.

Zoltan.





More information about the users mailing list