[Swift-user] Concatenating members of a string array
David Kelly
davidk at ci.uchicago.edu
Sun Sep 2 23:17:40 CDT 2012
Sheri,
This should be in trunk now. There is an example at http://www.ci.uchicago.edu/swift/guides/trunk/userguide/userguide.html#_strjoin. Please let me know if you have any questions.
Thanks,
David
----- Original Message -----
> From: "Michael Wilde" <wilde at mcs.anl.gov>
> To: "Sheri Mickelson" <mickelso at mcs.anl.gov>
> Cc: "swift user" <swift-user at ci.uchicago.edu>
> Sent: Tuesday, August 28, 2012 3:04:24 PM
> Subject: [Swift-user] Concatenating members of a string array
> Sheri, in response to your off-list question: here's two ways to
> concatenate a string array into a single string. We should provide a
> primitive to do this better / more reliably.
>
> The code below is a quick hack and needs polishing for the User Guide.
>
> - Mike
>
>
> string sa[] = ["aaa","bbb","ccc","ddd","eee"];
>
> string cs[];
>
> cs[-1] = "";
>
> foreach e,i in sa {
> cs[i] = @strcat(cs[i-1], " ", e);
> }
>
> trace("cat=",cs[@length(sa)-1]);
>
> type file;
>
> app (file o) echo (string s[])
> {
> echo s stdout=@filename(o);
> }
>
> file f = echo(sa);
>
> string os = readData(f);
>
> trace("os=",os);
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user
More information about the Swift-user
mailing list