KeyTake
KeyTake[assoc,{key1,key2,…}]
yields an association containing only the elements with keys keyi.
KeyTake[{assoc1,assoc2,…},keys]
gives a list of associations.
Details
- KeyTake[assoc,…] gives an Association object whose elements are in the order of the keyi.
- Any keyi that does not appear in assoc is ignored.
- KeyTake can be applied not only to Association objects, but also to lists of rules.
- KeyTake[keys][expr] is equivalent to KeyTake[expr,keys].
Examples
Basic Examples (7)
Select rules from an association, given a list of keys:
Select from several associations, given a list of keys:
Select rules from a list, given keys:
Select rules from several lists:
Select from an association, using a single key:
Select from a list, using a single key:
Use the operator form of KeyTake:
Text
Wolfram Research (2014), KeyTake, Wolfram Language function, https://reference.wolfram.com/language/ref/KeyTake.html.
CMS
Wolfram Language. 2014. "KeyTake." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/KeyTake.html.
APA
Wolfram Language. (2014). KeyTake. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KeyTake.html