genericClosure
lib.genericClosure
Primop
Docs pulled from | This Revision | 10 minutes ago
Takes 1 arguments
attrset
Takes an attrset with the following attributes:
startSet
[ Item ]- A list of start items. Each item must be an attrset containing a
key
. Thekey
must be comparable.
- A list of start items. Each item must be an attrset containing a
operator
Item -> [ Item ]- A function
returns a list of attrsets
GenericClosure starts with the startSet
and recursively
applying the operator
function to each item
. The attrsets in the
startSet
and the attrsets produced by operator
must contain a value
named key
which is comparable. The result is produced by calling operator
for each item
with a value for key
that has not been called yet including
newly produced item
s. The function terminates when no new item
s are
produced. The resulting list of attrsets contains only attrsets with a
unique key. For example,
builtins.genericClosure {
startSet = [ {key = 5;} ];
operator = item: [{
key = if (item.key / 2 ) * 2 == item.key
then item.key / 2
else 3 * item.key + 1;
}];
}
evaluates to
[ { key = 5; } { key = 16; } { key = 8; } { key = 4; } { key = 2; } { key = 1; } ]
Noogle detected
Detected Type
genericClosure :: AttrSet -> [AttrSet]
Implementation
This function is implemented in c++ and is part of the native nix runtime.