lib: improve implementation of foldAttrs

This commit is contained in:
h7x4
2026-07-30 23:49:08 +09:00
parent 69f6c0a1c5
commit 331c4cf699

View File

@@ -832,9 +832,7 @@ rec {
*/
foldAttrs =
op: nul: list_of_attrs:
foldr (
n: a: foldr (name: o: o // { ${name} = op n.${name} (a.${name} or nul); }) a (attrNames n)
) { } list_of_attrs;
mapAttrs (name: foldr op nul) (zipAttrs list_of_attrs);
/**
Recursively collect sets that verify a given predicate named `pred`