-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 list.insert(index, value) API to stdlib #2148
Conversation
1b54502
to
e4634b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! We'll need to rebase this PR/resolve conflicts and then add a test for the negative index case.
Currently, the PR is showing many commits from April 4th that already exist in the nightly
branch. If you use git rebase -i upstream/nightly
where upstream
is the corresponding git remote:
git remote -v
upstream [email protected]:modularml/mojo.git (fetch)
upstream [email protected]:modularml/mojo.git (push)
then you'll be able to see those commits not show up as duplicates in your PR. Please let me know if you run into any issues and I'll be happy to help.
c97ff8c
to
9e29bdf
Compare
7f5a393
to
528c276
Compare
Looks like CI is failing due to formatting. Do you mind running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just need to fix the formatting before we merge this. Thank you for your contribution! 🚀
assert_equal(vec[1], 2) | ||
assert_equal(vec[2], 3) | ||
|
||
vec.clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion Instead of manually running clear()
between the different parts of this function, it would read better to just use different variables, such as v1 = List[Int]()
, v2 = List[Int]()
, and so on. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah seems like a good idea
Signed-off-by: Dhaval Kumar <[email protected]>
Signed-off-by: Dhaval Kumar <[email protected]>
Signed-off-by: Dhaval Kumar <[email protected]>
Signed-off-by: Dhaval Kumar <[email protected]>
Signed-off-by: Dhaval Kumar <[email protected]>
528c276
to
a3365d3
Compare
Add `List.insert(index, value)` API as requested in modular#2134. This API should handle the same functionality as the Python `list.insert` and adds tests for the same. Fixes modular#2134 Signed-off-by: Dhaval Kumar <[email protected]>
…odular#2148) (#38047) Add `List.insert(index, value)` API as requested in [Internal Link] This API should handle the same functionality as the Python `list.insert` and adds tests for the same. Fixes [Internal Link] Signed-off-by: Dhaval Kumar <[email protected]> mojo-orig-commit: 98e062d modular-orig-commit: 5128d9ad94ee7acb9b876d3738e7ce47405afdab
…odular#2148) (#38047) Add `List.insert(index, value)` API as requested in [Internal Link] This API should handle the same functionality as the Python `list.insert` and adds tests for the same. Fixes [Internal Link] Signed-off-by: Dhaval Kumar <[email protected]> mojo-orig-commit: 98e062d modular-orig-commit: 5128d9ad94ee7acb9b876d3738e7ce47405afdab
…odular#2148) (#38047) Add `List.insert(index, value)` API as requested in modular#2134. This API should handle the same functionality as the Python `list.insert` and adds tests for the same. Fixes modular#2134 Signed-off-by: Dhaval Kumar <[email protected]> mojo-orig-commit: 98e062d MODULAR_ORIG_COMMIT_REV_ID: 5128d9ad94ee7acb9b876d3738e7ce47405afdab
…2148) (#38047) Add `List.insert(index, value)` API as requested in #2134. This API should handle the same functionality as the Python `list.insert` and adds tests for the same. Fixes #2134 Signed-off-by: Dhaval Kumar <[email protected]> mojo-orig-commit: 98e062d MODULAR_ORIG_COMMIT_REV_ID: 5128d9ad94ee7acb9b876d3738e7ce47405afdab
This pr serves to add
list.insert(index, value)
API to the stdlib as requested by issue #2134.This API should handle the same functionality as the python
list.insert
and adds tests for the same.