Re: Manipulate slice or specific element of range and return range

2018-03-28 Thread Timoses via Digitalmars-d-learn
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 =

Re: Manipulate slice or specific element of range and return range

2018-03-22 Thread David Bennett via Digitalmars-d-learn
On Thursday, 22 March 2018 at 04:49:39 UTC, Seb wrote: No need for regular expressions. D is powerful enough without them: ``` alias lowercased = (m, n) => m.take(n).asLowerCase.chain(m.drop(n)); ``` https://run.dlang.io/is/cSL0si And with the filter, so it passes the assert: ```

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Seb via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote: Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Timoses via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 12:07:49 UTC, Simen Kjærås wrote: On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote: unittest { assert("my capitalized string".capitalize == "myCapitalizedString"); } auto capitalize(string s) { import std.regex, std.uni; return

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Timoses via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 12:53:56 UTC, Ali Çehreli wrote: Here is another one that uses ForwardRange. import std.range; // empty, take, save, chain, popFrontN; import std.uni; // asLowerCase; import std.algorithm; // equal, filter; import std.conv; // text; auto initialLowerCased(R)(R

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Ali Çehreli via Digitalmars-d-learn
On 03/21/2018 04:30 AM, Timoses wrote: Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower case:     string m =

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote: Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower

Manipulate slice or specific element of range and return range

2018-03-21 Thread Timoses via Digitalmars-d-learn
Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower case: string m = "My Capital String"; string lower = m