-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
search function returns incorrect value #4988
Comments
There's a type, BOITTOM ==>> BOTTOM |
First, I should note that the behavior of For your particular case, because the first argument is a vector, you are asking it to search for any of several values. There's only one value (itself a vector) in your vector, but it's still a vector. The function returns a vector of results, and if the particular value is not found then it returns [] for that value. Let's move away from vectors-of-vectors because they confuse the issue; let's just search for numbers. Search for one entry, that's there, get one result:
Search for two entries, that are both there, get two results:
Three entries, one of them not found. Get three results, missing entry reported as
Two entries, one of them not found. Two results, missing entry reported as
Searching for one entry, not found. One result, missing entry reported as
Moving over to a slightly simplified variant of your example:
yields
So that's why it returns the result you see: you asked it to search for a vector of values, and it returned a vector of results, and the one entry in that vector of results is the empty vector.
|
#4989 for a proposal for a replacement. |
Describe the bug
When searching a vector of vectors for a vector, search returns [[]] instead of [] when no match is found.
Code reproducing the issue
FRONT = [0, 1, 0];
BACK = [0, -1, 0];
RIGHT = [1, 0, 0];
BOITTOM = [0, 0, -1];
b = [FRONT, BACK, RIGHT+BOTTOM];
echo(str([FRONT, BACK, RIGHT+BOTTOM]));
echo(str("FRONT ", FRONT, " ==> ", search([FRONT], [FRONT, BACK, RIGHT+BOTTOM])));
echo(str("RIGHT ", RIGHT, " ==> ", search([RIGHT], [FRONT, BACK, RIGHT+BOTTOM])));
echo(str("R+B ", RIGHT+BOTTOM, " ==> ", search([RIGHT + BOTTOM], [FRONT, BACK, RIGHT+BOTTOM])));
Output
Output of this code is
ECHO: "[[0, -1, 0], [0, 1, 0], [1, 0, -1]]"
ECHO: "FRONT [0, -1, 0] ==> [0]"
ECHO: "RIGHT [1, 0, 0] ==> [[]]" <==== Expected []
ECHO: "R+B [1, 0, -1] ==> [2]"
Environment and Version info (please complete the following information):
The text was updated successfully, but these errors were encountered: