genAttrs
lib.genAttrs
Docs pulled from | This Revision | about 1 hour ago
Generate an attribute set by mapping a function over a list of attribute names.
Inputs
names
-
Names of values in the resulting attribute set.
f
-
A function, given the name of the attribute, returns the attribute's value.
Type
genAttrs :: [ String ] -> (String -> Any) -> AttrSet
Examples
lib.attrsets.genAttrs
usage example
genAttrs [ "foo" "bar" ] (name: "x_" + name)
=> { foo = "x_foo"; bar = "x_bar"; }
Noogle detected
Implementation
The following is the current implementation of this function.
genAttrs =
names:
f:
listToAttrs (map (n: nameValuePair n (f n)) names);