Merge pull request #59777 from alyssais/converge
lib.converge: optimise
This commit is contained in:
commit
2b4bcb0344
@ -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
|
||||||
|
x' = f x;
|
||||||
|
in
|
||||||
|
if x' == x
|
||||||
then x
|
then x
|
||||||
else converge f (f 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user