diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-12-12 16:14:31 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-12-12 16:14:31 +0000 |
commit | 1a7e88bbd9290987e72616d42c9e9d344acc2a86 (patch) | |
tree | 6eb4f83ec6270a30cb137b5e84d0c380354bb5cb /doc/manual/writing-nix-expressions.xml | |
parent | 5e6699188fba38619dc23c0b65ee70849f90ea6c (diff) |
* New built-in function `builtins.attrNames' that returns the
names of the attributes in an attribute set.
Diffstat (limited to 'doc/manual/writing-nix-expressions.xml')
-rw-r--r-- | doc/manual/writing-nix-expressions.xml | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index 1cc5bb95b..9770e9182 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -1362,6 +1362,24 @@ is also available as <function>builtins.derivation</function>.</para> </varlistentry> + <varlistentry><term><function>builtins.attrNames</function> + <replaceable>attrs</replaceable></term> + + <listitem><para>Return the names of the attributes in the + attribute set <replaceable>attrs</replaceable> in a sorted list. + For instance, <literal>builtins.attrNames {y = 1; x = + "foo";}</literal> evaluates to <literal>["x" "y"]</literal>. + There is no built-in function <function>attrValues</function>, but + you can easily define it yourself: + +<programlisting> +attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames attrs);</programlisting> + + </para></listitem> + + </varlistentry> + + <varlistentry><term><function>baseNameOf</function> <replaceable>s</replaceable></term> <listitem><para>Return the <emphasis>base name</emphasis> of the |