Noogλe
search input
Function of the day
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. Thekeymust be comparable.
- A list of start items. Each item must be an attrset containing a
operatorItem -> [ Item ]- A function
returns a list of attrsets
GenericClosure starts with the
startSetand recursively applying theoperatorfunction to eachitem. The attrsets in thestartSetand the attrsets produced byoperatormust contain a value namedkeywhich is comparable. The result is produced by callingoperatorfor eachitemwith a value forkeythat has not been called yet including newly produceditems. The function terminates when no newitems 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; } ]