Skip to content
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

Add (unit) list utillity functions #623

Merged
merged 11 commits into from
Oct 24, 2024

Conversation

Goju-Ryu
Copy link
Contributor

@Goju-Ryu Goju-Ryu commented Oct 16, 2024

I found I needed some more functions to work with lists and unit_lists's for my human implementation to be more reliable. This PR contains those added functions as I feel like those changes are important on their own.

I've added the following utility functions:

  • core::list
    • contains
    • unique
  • core::numbers
    • is_zero
    • is_nonzero

I also changed the implementation of unit_list slightly to ignore the order of units in the list (always sorted in largest to smallest unit) and to remove duplicates. I was uncertain if this was desirable, but as no other configuration of units make sense for unit_list, I feel like this is a reasonable change.

examples/tests/lists.nbt Outdated Show resolved Hide resolved
examples/tests/lists.nbt Outdated Show resolved Hide resolved
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much. Added some minor comments.

@Goju-Ryu Goju-Ryu requested a review from sharkdp October 23, 2024 22:14
Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@sharkdp sharkdp merged commit da18b78 into sharkdp:master Oct 24, 2024
15 checks passed
@Goju-Ryu Goju-Ryu deleted the unit_list-utillity-functions branch October 27, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants