"Andrei Alexandrescu" wrote in message
news:ihf0kc$2fqj$1...@digitalmars.com...
> 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?
>
>
Daniel Gibson Wrote:
> Am 22.01.2011 18:46, schrieb Andrei Alexandrescu:
> > On 1/22/11 11:38 AM, Torarin wrote:
> >> 2011/1/22 Andrei Alexandrescu:
> >>> OK, so we have replace(haystack, needle, nail) which replaces _all_
> >>> occurrences of needle in haystack with nail. How would you call a
> >
On 1/22/11, spir wrote:
> In years and years of string processing, I have used maxreplace once, I
> guess, and the value was not 1.
Isn't Andrei talking about std.algorithm.replace, which should work
with any range and not just strings?
On 01/22/2011 05:27 PM, 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 runt
Daniel Gibson:
> IMHO replace (without eny suffix) sounds like it replaces every occurence.
> So just add replaceFirst for a function that replaces only the first
> occurence :)
OK.
Bye,
bearophile
2011/1/22 Andrei Alexandrescu :
> That's what I'm fearing - changing current replace to replaceAll and adding
> replace with the meaning of replaceFirst would silently change the semantics
> of existing code.
>
> Andrei
>
Yeah, I see that problem. I'm just so used to "replace first" being
the def
Torarin wrote:
> It sounds like the current replace should be named replaceAll.
That would break lots of existing code, and it doesn't seem to
fit.
If replacing only the first element means it can take a special
range, whereas all other n is is the same, it seems obvious
that replaceFirst be the
Am 22.01.2011 18:46, schrieb Andrei Alexandrescu:
On 1/22/11 11:38 AM, Torarin wrote:
2011/1/22 Andrei Alexandrescu:
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_ occu
On 1/22/11 11:38 AM, Torarin wrote:
2011/1/22 Andrei Alexandrescu:
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 fun
It sounds like the current replace should be named replaceAll.
Torarin
replaceAll
replaceN
replaceFirst
replaceLast
2011/1/22 Andrei Alexandrescu :
> 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 paramete
On 1/22/11 11:03 AM, Justin Johansson wrote:
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?
On 1/22/11 10:47 AM, Andrej Mitrovic wrote:
What if you want to replace a _count_ number of occurrences of needle
in haystack with nail? That's what Python's replace does, although I
think that only works for strings in Python.
A specific count is rare but can be added as a defaulted parameter.
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 p
What if you want to replace a _count_ number of occurrences of needle
in haystack with nail? That's what Python's replace does, although I
think that only works for strings in Python.
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 b
16 matches
Mail list logo