summary refs log tree commit diff
path: root/lib/fixed-points.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-04-17 15:55:57 +0100
committerAlyssa Ross <hi@alyssa.is>2019-04-17 15:55:57 +0100
commit7ed977e60d594929f290d5b31586c08ae674c695 (patch)
tree061f2d7e4fa94835eb5e5d024d0232329d70f4c3 /lib/fixed-points.nix
parent6336f9e6ea25bcc3f8049d56c660ebed5ac7d943 (diff)
downloadnixpkgs-7ed977e60d594929f290d5b31586c08ae674c695.tar
nixpkgs-7ed977e60d594929f290d5b31586c08ae674c695.tar.gz
nixpkgs-7ed977e60d594929f290d5b31586c08ae674c695.tar.bz2
nixpkgs-7ed977e60d594929f290d5b31586c08ae674c695.tar.lz
nixpkgs-7ed977e60d594929f290d5b31586c08ae674c695.tar.xz
nixpkgs-7ed977e60d594929f290d5b31586c08ae674c695.tar.zst
nixpkgs-7ed977e60d594929f290d5b31586c08ae674c695.zip
lib.converge: optimise
Diffstat (limited to 'lib/fixed-points.nix')
-rw-r--r--lib/fixed-points.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/fixed-points.nix b/lib/fixed-points.nix
index 2f818c88de5..968930526a6 100644
--- a/lib/fixed-points.nix
+++ b/lib/fixed-points.nix
@@ -30,9 +30,12 @@ rec {
   #     nix-repl> converge (x: x / 2) 16
   #     0
   converge = f: x:
-    if (f x) == x
-    then x
-    else converge f (f x);
+    let
+      x' = f x;
+    in
+      if x' == x
+      then x
+      else converge f x';
 
   # Modify the contents of an explicitly recursive attribute set in a way that
   # honors `self`-references. This is accomplished with a function