Open jamesnvc opened 6 years ago
Your expectation seems reasonable. I'll certainly consider patches if that's something you're interested in.
I suppose it might also be reasonable to iterate different minimums on backtracking, although I'm not sure whether that's useful or not.
Currently, if multiple elements in the list project to the same value, it will return the minimum of those set of values. For example,
Current behavior:
I would expect that the element that comes first in the list would be the one selected, e.g.
I am not sure the current behavior is necessarily "wrong", but I did find it somewhat unexpected. While it is somewhat justifiable, I find it makes the predicate less flexible, since if it just returned the first minimum value, I can pre-sort the list according to some other criteria and thereby control which minimum value will be returned.
This behavior happens because the predicate uses minimum_by with
compare
as the comparator, meaning it compares based on the entire pair, not just the projected value. I was able to get the behavior I was looking for by implementing minimum_with as follows(using a lambda for the compare function, but the idea being to just compare on the projected values).