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

Nat.digits() read-only accessor and Nat::Nat({ ...digits sequence...}) ctor #114

Closed
2 tasks done
saxbophone opened this issue May 30, 2022 · 0 comments · Fixed by #120
Closed
2 tasks done

Nat.digits() read-only accessor and Nat::Nat({ ...digits sequence...}) ctor #114

saxbophone opened this issue May 30, 2022 · 0 comments · Fixed by #120
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@saxbophone
Copy link
Owner

saxbophone commented May 30, 2022

  • Reading the digits of a Nat object is useful for optimising some algorithms (e.g. ilog(2, ...) can find the highest bit set)
  • Creating a Nat object from a sequence of digits could be useful. Such a feature will really come into its own if we ever get around to implementing compile-time pack()/unpack() functionality as described in compile-time pack() / unpack() methods for digits #63
constexpr const codlili::List<StorageType> digits() const { ... }

constexpr Nat(std::initializer_list<StorageType> digits) { ... }
constexpr Nat(std::span<StorageType> digits) { ... }
// requires Iterable<StorageType>.begin(), Iterable<StorageType>.end() to be valid statements
template <typename Iterable>
constexpr Nat(Iterable<StorageType> digits) { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant