-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
docs: add explanation to sort primop #14552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| 1. Transitivity | ||
| If a is less than b; b is less than c. Then it follows that a is less than c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| If a is less than b; b is less than c. Then it follows that a is less than c | |
| If a is less than b and b is less than c, then it follows that a is less than c. |
| If a is NOT less than b; b is NOT less then a; a and b are equal according to the comparator. | ||
| If b is equal to c then it follows that a is equal to c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| If a is NOT less than b; b is NOT less then a; a and b are equal according to the comparator. | |
| If b is equal to c then it follows that a is equal to c | |
| First, let us define *equivalence* with respect to some comparator: | |
| If x is *not* less than y and x is *not* less then y, then x and x are equivalent according to the comparator. | |
| Having done that, now we can define the transitivity of this equivalence: | |
| If a is equivalent to b and b is equivalent to c, then it follows that a is equivalent to c, |
I think using different variables here make the prose much less confusing. Your version IMO made the mistake of extending the a: b: ... scope too far: the second a and b are not the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, i can make the sentence more correct in that regard. But my other point was to avoid the term transitivity in its own definition. Because at that point i (or the reader) doesn't understand what it means.
I also wonder if we need to define the eq function, when the point is to explain the concept, we shouldn't over formalize, but make sure the required property is understood by keeping the explanation simple.
| If b is equal to c then it follows that a is equal to c | ||
| ```nix | ||
| let equiv = a: b: (!comparator a b && !comparator b a); in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let equiv = a: b: (!comparator a b && !comparator b a); in | |
| let equiv = x: y: (!comparator x y && !comparator x y); in |
Motivation
Reading through the docs of sort. I found them a bit hard to understand.
I think the code examples could benefit from some prose that explains them upfront.
It is non-obvious how to interpret the code. especially
->does this mean nix'simplicationoperator?Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.