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 join / merge method #80

Closed
evyasonov opened this issue Mar 6, 2023 · 2 comments
Closed

Add join / merge method #80

evyasonov opened this issue Mar 6, 2023 · 2 comments
Labels
enhancement New feature or request question Issue is a question

Comments

@evyasonov
Copy link

evyasonov commented Mar 6, 2023

Hi
Thank you for this great module
Can you please add a method to join a list of intervals the followin way:

portion.or_join(portion.open(i*10, i*10+1) for i in range(5))

It will be extreamly helpful
Thanks in advance

@AlexandreDecan AlexandreDecan added enhancement New feature or request question Issue is a question labels Mar 6, 2023
@AlexandreDecan
Copy link
Owner

You can already achieve the same result with portion.Interval(*[portion.open(i*10, i*10+1) for i in range(5)]).
More generally, you can rely on the operator module and the reduce function to achieve the same result. For example,

>>> from operator import or_
>>> from functools import reduce
>>> intervals = [portion.open(i*10, i*10+1) for i in range(5)]
>>> result = reduce(or_, intervals)

@evyasonov
Copy link
Author

Got it! Thank you for the answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Issue is a question
Projects
None yet
Development

No branches or pull requests

2 participants