summary refs log tree commit diff
path: root/doc/functions/library
diff options
context:
space:
mode:
authorJacek Galowicz <jacek@galowicz.de>2021-01-25 16:59:46 +0100
committerJacek Galowicz <jacek@galowicz.de>2021-01-28 23:08:59 +0100
commit123045a57056b997165be4963cbf62120a967fec (patch)
treedf971067e1c59e11fba585a121f060a3a49bd93d /doc/functions/library
parentd9353519d70454b53c6c302205272ccac81e1b7f (diff)
downloadnixpkgs-123045a57056b997165be4963cbf62120a967fec.tar
nixpkgs-123045a57056b997165be4963cbf62120a967fec.tar.gz
nixpkgs-123045a57056b997165be4963cbf62120a967fec.tar.bz2
nixpkgs-123045a57056b997165be4963cbf62120a967fec.tar.lz
nixpkgs-123045a57056b997165be4963cbf62120a967fec.tar.xz
nixpkgs-123045a57056b997165be4963cbf62120a967fec.tar.zst
nixpkgs-123045a57056b997165be4963cbf62120a967fec.zip
lib/attrsets: add cartesianProductOfSets function
Diffstat (limited to 'doc/functions/library')
-rw-r--r--doc/functions/library/attrsets.xml39
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/functions/library/attrsets.xml b/doc/functions/library/attrsets.xml
index 3c5823c2589..7ef0d16624c 100644
--- a/doc/functions/library/attrsets.xml
+++ b/doc/functions/library/attrsets.xml
@@ -1711,4 +1711,43 @@ recursiveUpdate
   </example>
  </section>
 
+ <section xml:id="function-library-lib.attrsets.cartesianProductOfSets">
+  <title><function>lib.attrsets.cartesianProductOfSets</function></title>
+
+  <subtitle><literal>cartesianProductOfSets :: AttrSet -> [ AttrSet ]</literal>
+  </subtitle>
+
+  <xi:include href="./locations.xml" xpointer="lib.attrsets.cartesianProductOfSets" />
+
+  <para>
+    Return the cartesian product of attribute set value combinations.
+  </para>
+
+  <variablelist>
+   <varlistentry>
+    <term>
+     <varname>set</varname>
+    </term>
+    <listitem>
+     <para>
+      An attribute set with attributes that carry lists of values.
+     </para>
+    </listitem>
+   </varlistentry>
+  </variablelist>
+
+  <example xml:id="function-library-lib.attrsets.cartesianProductOfSets-example">
+   <title>Creating the cartesian product of a list of attribute values</title>
+<programlisting><![CDATA[
+cartesianProductOfSets { a = [ 1 2 ]; b = [ 10 20 ]; }
+=> [
+     { a = 1; b = 10; }
+     { a = 1; b = 20; }
+     { a = 2; b = 10; }
+     { a = 2; b = 20; }
+   ]
+]]></programlisting>
+  </example>
+ </section>
+
 </section>