WLJS LogoWLJS Notebook

KeyTake

KeyTake[assoc, {key1, key2, ...}] yields an association containing only the elements with keys key_i.

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.

Examples

Take specific keys:

KeyTake[<|"a" -> 1, "b" -> 2, "c" -> 3|>, {"a", "c"}]
(* <|"a" -> 1, "c" -> 3|> *)

Operator form:

KeyTake[{"b"}][<|"a" -> 1, "b" -> 2, "c" -> 3|>]
(* <|"b" -> 2|> *)

Please visit the official Wolfram Language Reference for more details.

On this page