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 Indices of X in List #7323

Open
wants to merge 29 commits into
base: dev/feature
Choose a base branch
from

Conversation

Burbulinis
Copy link

@Burbulinis Burbulinis commented Dec 29, 2024

Description

This PR aims to add an expression to get the indices or positions of a list where the value at that index is the provided value.
The indices option is only allowed for variable lists, which returns strings. Whereas for positions it returns an integer. You can get the position of any list. For example:

set {_list::a} to 1
set {_list::b} to 2
set {_list::c} to 1
set {_list::d} to 2
set {_list::e} to 1

send all indices of the value 2 in {_list::*} # returns "b" and "c"
send all positions of the value 1 in {_list::*} # returns 1, 3, 5

send positions of value {_whatever} in (some expression that returns multiple values)
# allows non-literals and non-variable lists

This expression was merged with the current ExprIndexOf, which I renamed for clarity. The default, if you do not specify last or all is the first index/position. This is done to be consistent with the old ExprIndexOf.


Target Minecraft Versions: any
Requirements: none
Related Issues: #3933

Copy link
Member

@Efnilite Efnilite left a comment

Choose a reason for hiding this comment

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

very nois

@Efnilite Efnilite added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Dec 29, 2024
@Burbulinis Burbulinis requested a review from sovdeeth December 29, 2024 21:55
@Burbulinis Burbulinis requested a review from Moderocky December 30, 2024 12:21
@Moderocky Moderocky added the 2.10 Targeting a 2.10.X version release label Dec 30, 2024
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

I have forgotten that ExprIndexOf already exists. This needs to be merged with that

@Moderocky Moderocky added 2.11 Targeting a 2.11.X version release and removed 2.10 Targeting a 2.10.X version release labels Dec 31, 2024
Copy link
Contributor

@TheAbsolutionism TheAbsolutionism left a comment

Choose a reason for hiding this comment

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

My very important review

@Burbulinis Burbulinis requested a review from sovdeeth December 31, 2024 16:37
@Burbulinis Burbulinis requested a review from sovdeeth January 1, 2025 17:38
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

code looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.11 Targeting a 2.11.X version release enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants