Keys

Keys[key1val1,key2val2,]

gives a list of the keys keyi in an association.

Keys[{key1val1,key2val2,}]

gives a list of the keyi in a list of rules.

Keys[expr,h]

gives a list of keys in expr, wrapping each of them with head h before evaluation.

Details

  • Keys maintains the order of keys.
  • Keys[key->val] gives key.
  • Use Keys[expr,Hold] to extract keys without letting them evaluate.

Examples

open allclose all

Basic Examples  (4)

Get the keys in an association:

Get keys from a list of rules:

Keys automatically threads over lists:

Wrap keys with Hold to prevent evaluation:

Properties & Relations  (3)

Keys are listed in the order of their appearance:

Keys automatically threads over lists, but not associations:

Keys returns time stamps for a TimeSeries input:

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

Text

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

CMS

Wolfram Language. 2014. "Keys." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/Keys.html.

APA

Wolfram Language. (2014). Keys. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Keys.html

BibTeX

@misc{reference.wolfram_2024_keys, author="Wolfram Research", title="{Keys}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/Keys.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_keys, organization={Wolfram Research}, title={Keys}, year={2019}, url={https://reference.wolfram.com/language/ref/Keys.html}, note=[Accessed: 22-November-2024 ]}