Dictionaries · Lookup By Value · Practice Question
Extract the first key by value
Question
Given the dictionary:
dict:`a`b`c`d`e!2 3 4 5 3Extract the first key whose value is 3.
Solution
first where dict = 3dict = 3 produces the boolean dictionary `a`b`c`d`e!01001b; where returns the matching keys `b`e; first takes `b.
Alternative Solution
dict ? 3Find (?) returns the key of the first matching value directly — more concise for an exact-value lookup, but it doesn't generalise to a predicate like first where dict > 3.