Index of element in list #4478
Answered
by
TPGamesNL
honkling
asked this question in
Suggestions
-
Lists should be able to be searched for elements, so lists can be reliably manipulated. Example Usage set {_l::*} to 1, 2, 2, and 3
set {_i::*} to indices of 2 in {_l::*} # Returns [2, 3]
set {_i::*} to indices of 1 in {_l::*} # Returns [1]
set {_kvList::giga} to "chad"
set {_i::*} to indices of "chad" in {_kvList::*} # Returns ["giga"] Example use case # Let's say we have a list, {_chat::*}, which contains the last 100 chat messages sent. The index 100 is the newest chat message sent, and the index 0 is the oldest chat message sent, if any.
# If we know the chat message "hey guys!" is at index 54, we can just access that message using {_list::54}, but if somebody sends a chat message, then {_chat::54} would be a different chat message, for example, "icecream", instead of "hey guys!", like we expected.
# This problem could be solved using the "index of element in list" expression, using:
set {_c} to indices of "hey guys!" in {_chat::*} |
Beta Was this translation helpful? Give feedback.
Answered by
TPGamesNL
Dec 24, 2021
Replies: 2 comments 2 replies
-
This can technically already be done*, but having specific syntax for it would be neat! * |
Beta Was this translation helpful? Give feedback.
2 replies
-
See #3933 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
AyhamAl-Ali
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See #3933