Last active
October 21, 2020 11:44
-
-
Save pierric/40ec4c99c05b71a30a8ac6907efc08bc to your computer and use it in GitHub Desktop.
lens magic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = HashMap.fromList [ | |
("X", HashMap.fromList [("a", 0), ("b", 1)]), | |
("Y", HashMap.fromList [("a", 1)]), | |
("Z", HashMap.fromList [("b", 2)]) | |
] | |
I want to extract all value with key "a" in the nested HashMap, and keep the root key. | |
> m ^.. (itraversed <. at "a" . folded) . withIndex | |
result is [("X", 0), ("Y", 1)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment