Build all combinations of strings

Ali Çehreli acehreli at yahoo.com
Mon Jun 11 11:41:35 PDT 2012


On 06/11/2012 10:41 AM, Andrej Mitrovic wrote:
> Is there a Phobos function to turn this:
>
> string[] words = "foo bar doo".split();
>
> into:
>
> string[] res = ["foo bar doo",
>                  "foo doo bar",
>                  "bar foo doo",
>                  "bar doo foo",
>                  "doo foo bar",
>                  "doo bar foo"];
>
> So basically all combinations of some number of strings into a string
> array. I suppose there's some generic way to do this too.

I think "permutation" is a more accurate word in this case. This has 
been discussed before:

   http://forum.dlang.org/thread/ivd4ug$1rmh$1@digitalmars.com

Ali

-- 
D Programming Language Tutorial: http://ddili.org/ders/d.en/index.html


More information about the Digitalmars-d-learn mailing list