about summary refs log tree commit diff
path: root/tests/lang/lib.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-28T15·27+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-28T15·28+0200
commit50807f3dd5241667dac0c0cc302042d648de4b42 (patch)
tree3f6222262e66b64c2dc7479f618e2beb78faca9a /tests/lang/lib.nix
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 'tests/lang/lib.nix')
-rw-r--r--tests/lang/lib.nix6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/lang/lib.nix b/tests/lang/lib.nix
index 262cdd7e8fd0..028a538314b7 100644
--- a/tests/lang/lib.nix
+++ b/tests/lang/lib.nix
@@ -54,8 +54,8 @@ rec {
   const = x: y: x;
 
   range = first: last:
-    if builtins.lessThan last first
-    then []
-    else [first] ++ range (builtins.add first 1) last;
+    if first > last
+      then []
+      else genList (n: first + n) (last - first + 1);
 
 }