From 50807f3dd5241667dac0c0cc302042d648de4b42 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 28 Jul 2015 17:27:32 +0200 Subject: Add primop genList MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can be used to implement functions like ‘imap’ (or for that matter, ‘map’) without the quadratic complexity incurred by calling ‘++’ repeatedly. --- tests/lang/lib.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/lang') 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); } -- cgit 1.4.1