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
. 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 theoperator
function to eachitem
. The attrsets in thestartSet
and the attrsets produced byoperator
must contain a value namedkey
which is comparable. The result is produced by callingoperator
for eachitem
with a value forkey
that has not been called yet including newly produceditem
s. The function terminates when no newitem
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; } ]