October 27, 2018 Variant of chunkBy that can lazily split a string on case-changes | ||||
---|---|---|---|---|
| ||||
Have anybody implemented a lazy iteration algorithm similar to https://dlang.org/phobos/std_algorithm_iteration.html#chunkBy that can group elements using a binary predicate being able to do to the following. This example import std.ascii : isUpper, isLower; foreach (e; ["SomeCamelCaseName"].chunkByX!((a,b) => a.isUpper && b.isLower)) { writeln(e); } shall print Some Camel Case Name ? |
October 27, 2018 Re: Variant of chunkBy that can lazily split a string on case-changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Saturday, 27 October 2018 at 16:54:59 UTC, Per Nordlöw wrote: > that can group elements using a binary predicate being able to do to the following. Oops, turns out I already had this at https://github.com/nordlow/phobos-next/blob/721374f3815db41cc213b108f81ca13ea7b93721/src/slicing.d#L12 This is a less generic solution though with a unary predicate but it works in my case. Still looking for a more general solution. |
Copyright © 1999-2021 by the D Language Foundation