On 23/01/11 03:27, Andrei Alexandrescu wrote:
OK, so we have replace(haystack, needle, nail) which replaces _all_
occurrences of needle in haystack with nail. How would you call a
function that replaces only the _first_ occurrence of needle with nail?

Must be a distinct function, not a runtime parameter to the existing
function. This is because the function that replaces only one occurrence
only requires nail to be an input range.


Andrei

If you articulate this question to yourself over and over until you understand the *salient* problem (i.e. the real problem that sticks out) you will answer your own question and then have no need to resort to newsgroup answers.

If you are feeling lost, a good tactic to solve your problem is to think about function signatures in all their D glory not forgetting, of course, about D's innovative transitive xxx (const/immutable) constructs to include in the specification of your function(s).

Justin

Reply via email to