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

[mojo-stdlib] Add variadic initialiser, __iter__ and __contains__ to InlineList #2703

Closed

Conversation

ChristopherLR
Copy link

This PR adds some features to InlineList ( related issue #2658 )

Variadic initialiser

var x = InlineList[Int](1,2,3)

iter

var x = InlineList[Int](1,2,3)
for i in x:
    print(i)

contains

var x = InlineList[Int](1,2,3)
if 3 in x: print("ok")

- Variadic Initialisation
- Iteration
- Contains

Signed-off-by: Chris Sutton <christopher.sutton12@gmail.com>
Signed-off-by: Chris Sutton <christopher.sutton12@gmail.com>
Signed-off-by: Chris Sutton <christopher.sutton12@gmail.com>
Signed-off-by: Chris Sutton <christopher.sutton12@gmail.com>
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.

Awesome, thanks for making these improvements! Keep 'em coming! :)

@laszlokindrat laszlokindrat added the imported-internally Signals that a given pull request has been imported internally. label May 17, 2024
@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 the merged-internally Indicates that this pull request has been merged internally label May 17, 2024
_type_is_eq[ElementType, C](), "value type is not self.ElementType"
]()
for i in self:
if value == rebind[C](i[]):
Copy link
Contributor

@soraros soraros May 17, 2024

Choose a reason for hiding this comment

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

@laszlokindrat rebind doesn't work for mem types.

Copy link
Contributor

Choose a reason for hiding this comment

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

@soraros, right, I missed this, can you put up a patch to fix this? Or to document this limitation?

@modularbot modularbot added the merged-externally Merged externally in public mojo repo label May 18, 2024
modularbot pushed a commit that referenced this pull request May 18, 2024
…tains__ to InlineList (#40189)

[External] [mojo-stdlib] Add variadic initialiser, __iter__ and
__contains__ to InlineList

This PR adds some features to InlineList ( related issue #2658 )

*Variadic initialiser*
```mojo
var x = InlineList[Int](1,2,3)
```

*iter*
```mojo
var x = InlineList[Int](1,2,3)
for i in x:
    print(i)
```

*contains*
```mojo
var x = InlineList[Int](1,2,3)
if 3 in x: print("ok")
```

Co-authored-by: Chris <32541739+ChristopherLR@users.noreply.github.com>
Closes #2703
MODULAR_ORIG_COMMIT_REV_ID: 6a9eb7b41905e62f8db0855159fd851b7ffb6174
@modularbot
Copy link
Collaborator

Landed in d5b7381! Thank you for your contribution 🎉

@modularbot modularbot closed this May 18, 2024
msaelices pushed a commit to msaelices/mojo that referenced this pull request May 18, 2024
…tains__ to InlineList (#40189)

[External] [mojo-stdlib] Add variadic initialiser, __iter__ and
__contains__ to InlineList

This PR adds some features to InlineList ( related issue modularml#2658 )

*Variadic initialiser*
```mojo
var x = InlineList[Int](1,2,3)
```

*iter*
```mojo
var x = InlineList[Int](1,2,3)
for i in x:
    print(i)
```

*contains*
```mojo
var x = InlineList[Int](1,2,3)
if 3 in x: print("ok")
```

Co-authored-by: Chris <32541739+ChristopherLR@users.noreply.github.com>
Closes modularml#2703
MODULAR_ORIG_COMMIT_REV_ID: 6a9eb7b41905e62f8db0855159fd851b7ffb6174
martinvuyk pushed a commit to martinvuyk/mojo that referenced this pull request May 24, 2024
…tains__ to InlineList (#40189)

[External] [mojo-stdlib] Add variadic initialiser, __iter__ and
__contains__ to InlineList

This PR adds some features to InlineList ( related issue modularml#2658 )

*Variadic initialiser*
```mojo
var x = InlineList[Int](1,2,3)
```

*iter*
```mojo
var x = InlineList[Int](1,2,3)
for i in x:
    print(i)
```

*contains*
```mojo
var x = InlineList[Int](1,2,3)
if 3 in x: print("ok")
```

Co-authored-by: Chris <32541739+ChristopherLR@users.noreply.github.com>
Closes modularml#2703
MODULAR_ORIG_COMMIT_REV_ID: 6a9eb7b41905e62f8db0855159fd851b7ffb6174
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

4 participants