Skip to content

Enum.range - all elements of an enum, ordered #34

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

Closed
wants to merge 3 commits into from

Conversation

matthewleon
Copy link
Contributor

Once NonEmptyArrays and their generators are merged, this will allow us to randomly generate a BoundedEnum element in O(1), safely.

This is partly a successor to #33

I think that technically, this could be relaxed to work with Enums rather than just BoundedEnums, but that somehow feels like it's in violation of the intent of these two classes.

@matthewleon
Copy link
Contributor Author

Will revisit this shortly, as I think that with some changes it can be used to make more efficient default methods.

@matthewleon
Copy link
Contributor Author

To do this properly, I'll want NonEmptyArray: purescript/purescript-arrays#127

@matthewleon
Copy link
Contributor Author

Another note: not sure that Range is the right name for this. Maybe ElementSet?

Allows for faster default BoundedEnum implementations.
@matthewleon
Copy link
Contributor Author

Throwing a Map into this type should also allow a fromEnumFromRange giving O(logn) fromEnum.

@garyb
Copy link
Member

garyb commented Jan 28, 2018

enumerate?

@matthewleon
Copy link
Contributor Author

enumerate?

I like the sound of this. Maybe I name the type Enumeration and the function that produces it enumerate?

@matthewleon
Copy link
Contributor Author

Will resurrect this PR soon as Index, probably. Sorry for the noise.

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