Manipulate slice or specific element of range and return range
Timoses
timosesu at gmail.com
Wed Mar 21 11:30:28 UTC 2018
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
.filter!(c => c != ' ')
.<executeAt>!(0, c => c.toLower) // executeAt does not
exist
.array.to!string;
assert(lower == "myCapitalString");
or sth like
m.filter!(...)
.map!((element, int index) {
if (index == 0)
return element.toLower;
else
break; // stop since we are done manipulating
range
});
Anyway to do this?
More information about the Digitalmars-d-learn
mailing list