aboutsummaryrefslogtreecommitdiff
path: root/doc/manual
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-28 17:27:32 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-28 17:28:35 +0200
commit50807f3dd5241667dac0c0cc302042d648de4b42 (patch)
tree3f6222262e66b64c2dc7479f618e2beb78faca9a /doc/manual
parentf3dda728a4a92520ec9db7bd28a184af9c07db0d (diff)
Add primop genList
This can be used to implement functions like ‘imap’ (or for that matter, ‘map’) without the quadratic complexity incurred by calling ‘++’ repeatedly.
Diffstat (limited to 'doc/manual')
-rw-r--r--doc/manual/expressions/builtins.xml18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/manual/expressions/builtins.xml b/doc/manual/expressions/builtins.xml
index 099f90e78..446157056 100644
--- a/doc/manual/expressions/builtins.xml
+++ b/doc/manual/expressions/builtins.xml
@@ -364,6 +364,24 @@ builtins.fromJSON ''{"x": [1, 2, 3], "y": null}''
</varlistentry>
+ <varlistentry><term><function>builtins.genList</function>
+ <replaceable>generator</replaceable> <replaceable>length</replaceable></term>
+
+ <listitem><para>Generate list of size
+ <replaceable>length</replaceable>, with each element
+ <replaceable>i></replaceable> equal to the value returned by
+ <replaceable>generator</replaceable> <literal>i</literal>. For
+ example,
+
+<programlisting>
+builtins.genList (x: x * x) 5
+</programlisting>
+
+ returns the list <literal>[ 0 1 4 9 16 ]</literal>.</para></listitem>
+
+ </varlistentry>
+
+
<varlistentry><term><function>builtins.getAttr</function>
<replaceable>s</replaceable> <replaceable>set</replaceable></term>