3
0
Fork 0
forked from mirrors/nixpkgs

lib.converge: optimise

This commit is contained in:
Alyssa Ross 2019-04-17 15:55:57 +01:00
parent 6336f9e6ea
commit 7ed977e60d
No known key found for this signature in database
GPG key ID: C4844408C0657052

View file

@ -30,9 +30,12 @@ rec {
# nix-repl> converge (x: x / 2) 16 # nix-repl> converge (x: x / 2) 16
# 0 # 0
converge = f: x: converge = f: x:
if (f x) == x let
then x x' = f x;
else converge f (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 # Modify the contents of an explicitly recursive attribute set in a way that
# honors `self`-references. This is accomplished with a function # honors `self`-references. This is accomplished with a function