reduce string ranges

Brian Myers bmyers at harryanddavid.com
Wed Jun 4 17:09:45 PDT 2008


Well yes and no. I have posted about the map and reduce templates before a few days ago, but this is with a different function -- string concatenation.

I'm just exploring how well D supports the functional paradigm. 2.0 is bringing in a lot of functional features, and I'm trying to get a feel for the boundaries.

Brian

bearophile Wrote:

> Brian Myers:
> > I'd like to be able to use the reduce template on a range of strings. The following:
> > int main(char[][] args)
> > {
> >     string[] tstarr = ["one", "two", "three"];
> >     writefln(reduce!("a ~ b")("", tstarr));
> > }
> 
> Don't do that, probably it's a slow way to join an array of strings.
> In the std.string module you can use the join("") function, or you can use joinArr() function from the d.string module of mine.
> (I have like a dejavu, isn't this discussion happened already?)
> 
> Bye,
> bearophile




More information about the Digitalmars-d mailing list