KeyTake

KeyTake[assoc,{key1,key2,}]

yields an association containing only the elements with keys keyi.

KeyTake[{assoc1,assoc2,},keys]

gives a list of associations.

KeyTake[{key1,key2,}]

represents an operator form of KeyTake that can be applied to an expression.

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:

Wolfram Research (2014), KeyTake, Wolfram Language function, https://reference.wolfram.com/language/ref/KeyTake.html.

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

BibTeX

@misc{reference.wolfram_2023_keytake, author="Wolfram Research", title="{KeyTake}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/KeyTake.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_keytake, organization={Wolfram Research}, title={KeyTake}, year={2014}, url={https://reference.wolfram.com/language/ref/KeyTake.html}, note=[Accessed: 19-March-2024 ]}