query
On this page

mapAttrs

builtins.mapAttrs

Primop
Docs pulled from | This Revision | 24 minutes ago

Takes 2 arguments

f, attrset


Apply a function to each element in an attribute set, creating a new attribute set.

Inputs

f

A function that takes an attribute name and its value, and returns the new value for the attribute.

attrset

The attribute set to iterate through.

Type

mapAttrs :: (String -> Any -> Any) -> AttrSet -> AttrSet

Examples

lib.attrsets.mapAttrs usage example

mapAttrs (name: value: name + "-" + value)
   { x = "foo"; y = "bar"; }
=> { x = "x-foo"; y = "y-bar"; }
This function is not defined in a .nix file. It is likely a builtins function or an alias of a builtins function. builtins functions are predefined functions provided by Nix.
(lib.attrsets.mapAttrs)

Noogle detected

Aliases

Implementation

This function is implemented in c++ and is part of the native nix runtime.