Re: mismatch and return value

2016-07-13 Thread celavek via Digitalmars-d-learn
Thank you both for the very good insights. Community wise +1 :)

Re: mismatch and return value

2016-07-13 Thread ketmar via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:11:51 UTC, celavek wrote: I misunderstood the doc and I got a bit confused by the range - in C++ I would have incremented the iterators but here I did not know what to do exactly as I could not match the 2 different concepts in functionality. it mostly maps to

Re: mismatch and return value

2016-07-13 Thread ketmar via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:13:00 UTC, Mike Parker wrote: To be fair, I think it's only obvious to someone who has achieved a certain level of comfort and familiarity with ranges and the range-based functions in Phobos. This particular function could just as easily be inferred to return an

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:11:51 UTC, celavek wrote: Thank you for the example. I misunderstood the doc and I got a bit confused by the range - in C++ I would have incremented the iterators but here I did not know what to do exactly as I could not match the 2 different concepts in funct

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:10:11 UTC, ketmar wrote: On Wednesday, 13 July 2016 at 11:06:56 UTC, celavek wrote: On Wednesday, 13 July 2016 at 10:41:44 UTC, ketmar wrote: I understand your point but it should not be a matter of guessing. It should be explicitly stated by the documentation.

Re: mismatch and return value

2016-07-13 Thread celavek via Digitalmars-d-learn
Thank you for the example. I misunderstood the doc and I got a bit confused by the range - in C++ I would have incremented the iterators but here I did not know what to do exactly as I could not match the 2 different concepts in functionality.

Re: mismatch and return value

2016-07-13 Thread ketmar via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 11:06:56 UTC, celavek wrote: On Wednesday, 13 July 2016 at 10:41:44 UTC, ketmar wrote: I understand your point but it should not be a matter of guessing. It should be explicitly stated by the documentation. then people will start to complain that documentation is

Re: mismatch and return value

2016-07-13 Thread celavek via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 10:41:44 UTC, ketmar wrote: let's read the doc again: "Returns a tuple with the reduced ranges that start with the two mismatched values." simple logic allows us to guess that it should return tuple with two empty ranges. and it really does. I understand your

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 09:59:30 UTC, celavek wrote: Hi, I am trying to use the function "mismatch" from std.algorithm.comparison like so: int count = 0; auto m = mismatch(lhs, rhs); while (!m[0].empty) { ++count; m = mismatch(m[0], m[1]); } That goes into an infinite loop. Wh

Re: mismatch and return value

2016-07-13 Thread ketmar via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 09:59:30 UTC, celavek wrote: That goes into an infinite loop. sure. let's read the docs: "Returns a tuple with the reduced ranges that start with the two mismatched values." so, if it will find mismatch, it will loop forever then, as you forgot to pop one of the

Re: mismatch and return value

2016-07-13 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 13 July 2016 at 09:59:30 UTC, celavek wrote: As a side note the documentation of the standard library is not digestible to say the least - there is missing info(e.g. what does mismatch return if no mismatch found) and lacks user-friendliness and details. Whenever you find areas

mismatch and return value

2016-07-13 Thread celavek via Digitalmars-d-learn
Hi, I am trying to use the function "mismatch" from std.algorithm.comparison like so: int count = 0; auto m = mismatch(lhs, rhs); while (!m[0].empty) { ++count; m = mismatch(m[0], m[1]); } That goes into an infinite loop. What does mismatch return when it cannot actually find a mis