Wolfram: Association. Delete Items by Key
Delete by Key
KeyDrop
-
KeyDrop[asso, key]
KeyDrop[asso, listOfKeys]
KeyDrop[listOfAsso, key]
return a new association with some keys removed. (does not modify variable)
KeyDrop[ Association[ a -> 1, b -> 2, c -> 3 ], b ] (* <|a -> 1, c -> 3|> *)
KeyDrop[ Association[ a -> 1, b -> 2, c -> 3 ], {c, b} ] (* <|a -> 1|> *)
KeyDrop[ {Association[ a -> 1, b -> 2, c -> 3 ], Association[ a -> 11, b -> 22 ]}, b ] (* {<|a -> 1, c -> 3|>, <|a -> 11|>} *)
Association Variable, Delete by Key, Modify Variable
KeyDropFrom[assoVar, key]
-
- remove the element with the specified key.
- modify the variable.
- return the new value of the variable.
xx = Association[ a -> 1, b -> 2]; KeyDropFrom[ xx, b ] (* <|a -> 1|> *) xx (* <|a -> 1|> *)
KeyDropFrom[assoVar, listOfKeys]
-
remove multiple elements.
xx = Association[ a -> 1, b -> 2, c -> 3, d -> 4]; KeyDropFrom[ xx, {a, c} ] (* <|b -> 2, d -> 4|> *)
WolframLang, Association (Key Value List)
- Wolfram: Association (Key Value List)
- Wolfram: Create Association
- Wolfram: Association. Get Value
- Wolfram: Association. Check Key Exist
- Wolfram: Association. Check Value Exist
- Wolfram: Association. Add Item
- Wolfram: Association. Delete Items by Key
- Wolfram: Association. Delete Items by Index
- Wolfram: Association. Delete Items by Filter
- Wolfram: Association. Sort
- Wolfram: Association. Union, Intersection, Complement, Etc
- Wolfram: Map f to Association
- Wolfram: Association to List, Get All Keys or Values