about summary refs log tree commit diff
path: root/doc/manual/writing-nix-expressions.xml
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-12T16·14+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-12T16·14+0000
commit1a7e88bbd9290987e72616d42c9e9d344acc2a86 (patch)
tree6eb4f83ec6270a30cb137b5e84d0c380354bb5cb /doc/manual/writing-nix-expressions.xml
parent5e6699188fba38619dc23c0b65ee70849f90ea6c (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.xml18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml
index 1cc5bb95b8c3..9770e91822b5 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