digitalmars.D - Lazy generic std.algorithm.replace()
- =?UTF-8?B?Tm9yZGzDtnc=?= (18/18) Oct 23 2015 Is there a reason why std.algorithm doesn't provide a lazy range
- =?UTF-8?B?Tm9yZGzDtnc=?= (4/6) Oct 23 2015 Sample implementation at
- =?UTF-8?B?Tm9yZGzDtnc=?= (3/5) Oct 23 2015 Made it variadic at
- =?UTF-8?B?Tm9yZGzDtnc=?= (3/9) Oct 23 2015 Added hashed based version at
Is there a reason why std.algorithm doesn't provide a lazy range implementation of replace()? I'm aware this isn't difficult to express using `map` like, for instance, auto replace(S, F, T)(S, F from, T to) { return s.map!(a => a == from ? to : a); } but I prefer syntactic sugars. While at it we could make use of variadics to enable syntax such as assert(equal("do_it".replace('_', ' ', 'd', 'g', 'i', 't', 't', 'o', "go to"); along with optional predicate (as usual). What do you say?
Oct 23 2015
On Friday, 23 October 2015 at 11:23:55 UTC, Nordlöw wrote:Is there a reason why std.algorithm doesn't provide a lazy range implementation of replace()?Sample implementation at https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1939 for one replacement pair.
Oct 23 2015
On Friday, 23 October 2015 at 11:53:06 UTC, Nordlöw wrote:https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1939 for one replacement pair.Made it variadic at https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1950
Oct 23 2015
On Friday, 23 October 2015 at 21:44:28 UTC, Nordlöw wrote:On Friday, 23 October 2015 at 11:53:06 UTC, Nordlöw wrote:Added hashed based version at https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1999https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1939 for one replacement pair.Made it variadic at https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L1950
Oct 23 2015