【发布时间】:2018-02-12 14:11:09
【问题描述】:
如果原子在值列表中,是否有一种简洁的方法可以通过原子值查找字典的键?
假设:字典的值列表具有每个唯一的元素
例子:
d:`tech`fin!(`aapl`msft;`gs`jpm) / would like to get key `fin by looking up `jpm
d?`gs`jpm / returns `fin as expected
d?`jpm / this doesn't work unfortunately
$[`jpm in d`fin;`fin;`tech] / this is the only way I can come up with
最后一个选项不能很好地随着键的数量而扩展
谢谢!
【问题讨论】: