In D how do i apply a function to all elements in an array?
For example i want to apply the std.string.leftJustify() function to all elements in a string array.
I know i could use a loop but is there a nice map function? I see there is one in the std.algorithm library but i’ve no idea how to use templates in D yet.
Any examples?
There are a lot of options to specify the lambda.
mapreturns a range that lazily evaluates as it is consumed. You can force immediate evaluation using the functionarrayfromstd.array.