I’m wondering on how to retrieve the key given the value of a dictionary?
The way to get value given the key is
array[key] - this will output the value, but what if I have the value and am looking to get the key?
I’m wondering on how to retrieve the key given the value of a dictionary?
The way to get value given the key is
array[key] - this will output the value, but what if I have the value and am looking to get the key?
q)d:a
bc!1 2 3 q)d[
a] 1 q)d?1 a q)d:
ab
cd!1 2 3 1 q)d?1
a
be mindful, with this method and duplicate values, only the first key is returned
This is exactly, what I’ve been looking for, thank you!
you also can use where clause, which return all keys that have duplicates:
q)dic:a
bc
d!1 2 3 1
q)where dic=1
q)a
d
q)