On Thursday, 22 March 2018 at 07:34:18 UTC, David Bennett wrote:
On Thursday, 22 March 2018 at 04:49:39 UTC, Seb wrote:
```
alias lowercased = (m, n) => m.take(n).asLowerCase.chain(m.drop(n));
```

```
string input = "My Capital String";
auto lower1 = input.take(1).asLowerCase.chain(input.drop(1).filter!(c => c != ' ')).array;
assert(lower1 == "myCapitalString");
```

Also a few more options (including a slice version):

https://run.dlang.io/is/dZHcSo

As the input is never read until the array() is run, each element in the array should only be copied from RAM to the stack once.

And if you compile with LDC a lot of it can be inlined and the stack copies of the range structs and elements should be minimised even further.

Very inspiring snippets!

Reply via email to