什么是简洁/优雅的方式放入相应条件为真的地图键值对?
那是翻译
[condition1 condition2 ...] [key1 val1 key2 val2 ...]
Run Code Online (Sandbox Code Playgroud)
要么
[condition1 condition2 ...] [key1 key2 ...] [val1 val2 ...]
Run Code Online (Sandbox Code Playgroud)
要么
[condition1 key1 val1 condition2 key2 val2...]
Run Code Online (Sandbox Code Playgroud)
成
{key-for-true-condition1 val-for-true-condition1, key-for-true-condition2 val-for-true-condition2...}
Run Code Online (Sandbox Code Playgroud)
我认为在其lambda中使用"if"和"if"但是对更简洁/美丽/优雅/惯用的方式感兴趣.
(into {} (for [[c k v] (partition 3 coll) :when c]
[k v]))
Run Code Online (Sandbox Code Playgroud)
基于金太郎的'for'版本,但更短.