On Wednesday, 16 October 2019 at 19:25:18 UTC, DNoob wrote:
I'm just learning D, so it's very possible that I'm missing a more appropriate function that exists elsewhere, but basically I found today that while I could easily write a cmp function that worked for everything, the one in std.algorithm doesn't seem to:

std.algorithm.cmp compares two ranges, not two values. From the documentation:

Performs a lexicographical comparison on two input ranges. Iterating r1 and r2 in lockstep, cmp compares each element e1 of r1 with the corresponding element e2 in r2. If one of the ranges has been finished, cmp returns a negative value if r1 has fewer elements than r2, a positive value if r1 has more elements than r2, and 0 if the ranges have the same number of elements.

Source: https://dlang.org/phobos/std_algorithm_comparison.html#.cmp

Reply via email to