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 USet class #58

Open
bleudev opened this issue Nov 8, 2024 · 0 comments · May be fixed by #59
Open

Add USet class #58

bleudev opened this issue Nov 8, 2024 · 0 comments · May be fixed by #59
Assignees
Milestone

Comments

@bleudev
Copy link
Member

bleudev commented Nov 8, 2024

Description of new feature

I suggest to add USet and UInterval classes for simplyfing working with sets and intervals.

from ufpy import USet, inf

# Sets
USet.U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 74} # set universal (in sys.environ)

a = USet(1, 9, 2)
b = Uset(9, 1, 12, 74)

a & b # u{1, 9}
a | b # u{1, 2, 9, 12, 74}
a - b # u{2}

-a # not op; eq. of "USet.U - a"; u{3, 4, 5, 6, 7, 8, 12, 74}
# Note: if in b there are elements, that not in USet.U, USet.U += {this elements} automaticly

# From bool logic
a > b # a -> b; implication

# Intervals
a = UInterval(-inf, 5) # u(-∞, 5)
b = UInterval([3], +inf) # u[3, +∞)

a | b # u(-∞; +∞)
a & b # u[3; 5)
a - b # (-∞; 3)

-a # u[5, +∞)

Use Case (optional)

In Math exercises.

Suggest solution (optional)

@bleudev bleudev added the new feature New feature label Nov 8, 2024
@bleudev bleudev self-assigned this Nov 8, 2024
@bleudev bleudev added this to Ufpy Nov 8, 2024
@github-project-automation github-project-automation bot moved this to ⚠ To-Do in Ufpy Nov 8, 2024
@bleudev bleudev added this to the 0.3 milestone Nov 8, 2024
@bleudev bleudev linked a pull request Nov 9, 2024 that will close this issue
6 tasks
@bleudev bleudev linked a pull request Nov 9, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ⚠ To-Do
Development

Successfully merging a pull request may close this issue.

1 participant