-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
doc: improve lib.compareLists documentation #368360
Conversation
a794e90
to
9e955a9
Compare
9e955a9
to
7c2573c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
7c2573c
to
ea5e99f
Compare
lib/lists.nix
Outdated
Compare two lists element-by-element. | ||
Compare two lists element-by-element with a comparison function `cmp`. | ||
|
||
List elements are compared in order, the first non-equal pair of elements determines the result. |
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's be explicit
List elements are compared in order, the first non-equal pair of elements determines the result. | |
List elements are compared in order, the first non-equal pair of elements determines the result, which is expressed as an integer: | |
- `-1` if the first element of the first unequal pair is less | |
- `1` if the first element of the first unequal pair is greater | |
- `0` if all elements are equal |
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.
This is already described in the comparison function
argument. I would try to not duplicate this information.
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.
The output of the function should be at the top, I found it hard to grasp what the thing is doing before reading the details. And the final outcome not strictly implied by the signature of the comparison function. We can also describe the output indirectly, e.g.
The result is the integer returned by the comparison function for the first unequal pair in the list, or `0`.
ea5e99f
to
477b98b
Compare
Improve the documentation of
lib.compareLists
I was motivated by seeing the current documentation of the noogle.dev function of the day 😄
This made me thinking: "we already have a language operator for list comparison ... so whats the difference here"
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.