{lib, ...}: rec { min = a: b: if a < b then a else b; max = a: b: if a > b then a else b; # build list of `len` lists of `n` elements of `xs` windows = with builtins; n: xs: let len = length xs; n' = min n len; # when len = n, there is still one window num-windows = max 0 (len - n' + 1); in genList # for i in 0..len (i: genList # for j in 0..n -> xs[i + j] (j: elemAt xs (i + j)) n') num-windows; isEmptySet = set: with builtins; length (attrNames set) == 0; }