Search code examples
functional-programmingd

Reduce with seed an array of strings


Is it possible to perform std.algorithm.reduce with the seed being an array of strings? Something like this:

reduce!(string[], (r,c) => r ~= c)([], someIterable);

Solution

  • Sure, but due to the nature of dynamic arrays you have to declare it first:

    string[] arr;
    reduce!((r, c) => r~=c)(arr, someIterable);