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

[stdlib] Add builtin any()/all() functions #2600

Closed
wants to merge 1 commit into from

Conversation

helehex
Copy link
Contributor

@helehex helehex commented May 9, 2024

Adds builtin functions for testing if there are truthy elements in List, Set, SIMD.
Should change to check iterators eventually.

Also mentioned here

@helehex helehex requested a review from a team as a code owner May 9, 2024 16:15
@helehex helehex force-pushed the stdlib/any-all branch 3 times, most recently from 2347a27 to 4983c90 Compare May 10, 2024 21:18
@JoeLoser
Copy link
Collaborator

JoeLoser commented May 11, 2024

Nice, thank you! This will be useful and I can't wait for us to get further along with iterators and algorithms. Do you mind adding a changelog entry here please for this work?

@helehex
Copy link
Contributor Author

helehex commented May 13, 2024

I have another one ready for bitwise reduce_and()/reduce_or(), but waiting on this and simd bool constrain to go through .

@helehex
Copy link
Contributor Author

helehex commented May 13, 2024

now i feel like these all should've been done in one go to avoid the intermediate problems, but i guess there's a chance bitwise reduce might not be desired

@helehex
Copy link
Contributor Author

helehex commented May 13, 2024

oh i forgot the changelog entry, hang on

@helehex helehex requested a review from a team as a code owner May 13, 2024 09:43
@helehex
Copy link
Contributor Author

helehex commented May 13, 2024

there's a typo in the changelog under the repr() section, I think by [@mikowals] should be by [@gabrieldemarmiesse]

@helehex
Copy link
Contributor Author

helehex commented May 15, 2024

i guess we might want all() of an empty iterator to return True?

@artemiogr97
Copy link
Contributor

i guess we might want all() of an empty iterator to return True?

I'd say to match the python behavior (I have not checked)

@Brian-M-J
Copy link

Here are the Python docs for reference:

any:

Return True if any element of the iterable is true. If the iterable is empty, return False.

all:

Return True if all elements of the iterable are true (or if the iterable is empty).

…truthy

Signed-off-by: Max Brylski <helehex@gmail.com>
@laszlokindrat laszlokindrat added the imported-internally Signals that a given pull request has been imported internally. label May 16, 2024
Copy link
Contributor

@laszlokindrat laszlokindrat left a comment

Choose a reason for hiding this comment

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

This is great, thank you for working on this!

@modularbot
Copy link
Collaborator

✅🟣 This contribution has been merged 🟣✅

Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.

We use Copybara to merge external contributions, click here to learn more.

@modularbot modularbot added merged-internally Indicates that this pull request has been merged internally merged-externally Merged externally in public mojo repo labels May 16, 2024
modularbot pushed a commit that referenced this pull request May 16, 2024
[External] [stdlib] Add builtin `any()`/`all()` functions

Adds builtin functions for testing if there are truthy elements in
`List`, `Set`, `SIMD`.
Should change to check iterators eventually.

Also mentioned [here](#2502)

---------

Co-authored-by: Helehex <Helehex@gmail.com>
Closes #2600
MODULAR_ORIG_COMMIT_REV_ID: 894768635c30c41fa359a69e5110b60adce735f8
@modularbot
Copy link
Collaborator

Landed in f8a9dd0! Thank you for your contribution 🎉

@modularbot modularbot closed this May 16, 2024
lsh pushed a commit to lsh/mojo that referenced this pull request May 17, 2024
[External] [stdlib] Add builtin `any()`/`all()` functions

Adds builtin functions for testing if there are truthy elements in
`List`, `Set`, `SIMD`.
Should change to check iterators eventually.

Also mentioned [here](modularml#2502)

---------

Co-authored-by: Helehex <Helehex@gmail.com>
Closes modularml#2600
MODULAR_ORIG_COMMIT_REV_ID: 894768635c30c41fa359a69e5110b60adce735f8

Signed-off-by: Lukas Hermann <lukashermann28@gmail.com>
msaelices pushed a commit to msaelices/mojo that referenced this pull request May 18, 2024
[External] [stdlib] Add builtin `any()`/`all()` functions

Adds builtin functions for testing if there are truthy elements in
`List`, `Set`, `SIMD`.
Should change to check iterators eventually.

Also mentioned [here](modularml#2502)

---------

Co-authored-by: Helehex <Helehex@gmail.com>
Closes modularml#2600
MODULAR_ORIG_COMMIT_REV_ID: 894768635c30c41fa359a69e5110b60adce735f8
modularbot pushed a commit that referenced this pull request May 22, 2024
…bitwise operations (#40348)

[External] [stdlib] Change `SIMD.reduce_and()`/`SIMD.reduce_or()` to
bitwise operations

changes the behavior of simd `reduce_and()`/`reduce_or()` to be bitwise
operations.

Theres a few things that are related to this:
[builtin `any()`/`all()`
functions](#2600)
[constrain simd bool to
size=1](#2502)

Co-authored-by: Helehex <Helehex@gmail.com>
Closes #2671
MODULAR_ORIG_COMMIT_REV_ID: 1ab75b0817529420ea8dd4baf3014ea97dc162ad
martinvuyk pushed a commit to martinvuyk/mojo that referenced this pull request May 24, 2024
[External] [stdlib] Add builtin `any()`/`all()` functions

Adds builtin functions for testing if there are truthy elements in
`List`, `Set`, `SIMD`.
Should change to check iterators eventually.

Also mentioned [here](modularml#2502)

---------

Co-authored-by: Helehex <Helehex@gmail.com>
Closes modularml#2600
MODULAR_ORIG_COMMIT_REV_ID: 894768635c30c41fa359a69e5110b60adce735f8
martinvuyk pushed a commit to martinvuyk/mojo that referenced this pull request May 24, 2024
…bitwise operations (#40348)

[External] [stdlib] Change `SIMD.reduce_and()`/`SIMD.reduce_or()` to
bitwise operations

changes the behavior of simd `reduce_and()`/`reduce_or()` to be bitwise
operations.

Theres a few things that are related to this:
[builtin `any()`/`all()`
functions](modularml#2600)
[constrain simd bool to
size=1](modularml#2502)

Co-authored-by: Helehex <Helehex@gmail.com>
Closes modularml#2671
MODULAR_ORIG_COMMIT_REV_ID: 1ab75b0817529420ea8dd4baf3014ea97dc162ad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported-internally Signals that a given pull request has been imported internally. merged-externally Merged externally in public mojo repo merged-internally Indicates that this pull request has been merged internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants