jfmengels/elm-review-simplify
在 GitHub 查看Remove duplicate entries in Set.fromList/Dict.fromList
Open
#326 创建于 2024年12月13日
enhancementhelp wanted
仓库指标
- Star
- (22 star)
- PR 合并指标
- (PR 指标待抓取)
描述
If some of the keys are the same, then we can remove some of them (potentially telling the user there's a problem with their setup).
Dict.fromList [ ( 1, a ), ( 2, b ), ( 3, c ), ( 1, d ) ]
--> ✔
Dict.fromList [ ( 2, b ), ( 3, c ), ( 1, d ) ]
Dict.fromList [ ( 1, a ), ( 2, b ), ( 3, c ) ]
|> Dict.insert 1 d
-->
Dict.fromList [ ( 2, b ), ( 3, c ) ]
|> Dict.insert 1 d
--> Or alternatively put it directly in the list, probably nicer
Dict.fromList [ ( 2, b ), ( 3, c ), ( 1, d ) ]
Set.fromList [ 1, 2, 3, 1 ]
--> ✔
Set.fromList [ 2, 3, 1 ]
--> or remove the later one 🤷
Set.fromList [ 1, 2, 3 ]
Set.fromList [ 1, 2, 3 ]
|> Set.insert 1
-->
Set.fromList [ 1, 2, 3 ]