F# 相当于 toLookup
鉴于此:
[
("A","A122");
("A","A123");
("B","B122");
("B","B123");
("C","C122");
]
是否有标准函数可以实现此目的?
[
("A",["A122";"A123"]);
("B",["B122";"B123"]);
("C",["C122"])
]
我想到了 Seq.distinctBy、List.partition、Set、Map,但似乎都不是我要找的。
谢谢...在我等待的时候,我会尝试自己推出:)
Given this:
[
("A","A122");
("A","A123");
("B","B122");
("B","B123");
("C","C122");
]
Is there a standard function to get this?
[
("A",["A122";"A123"]);
("B",["B122";"B123"]);
("C",["C122"])
]
I thought of Seq.distinctBy, List.partition, Set, Map, but none of them seem to be what I'm looking for.
Thanks... while I'm waiting, I'll try to roll my own :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
愚蠢的我,我没有注意到 Seq.groupBy!
输出 :
Silly me, I didn't notice Seq.groupBy!
Output :
对于 O(1) 查找:
For O(1) lookup: