{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; # convert an rgb colour string from the form "#rrggbb" to "#rrggbbff" rgbToRgba = rgb: let hex = builtins.replaceStrings [ "#" ] [ "" ] rgb; r = builtins.substring 0 2 hex; g = builtins.substring 2 2 hex; b = builtins.substring 4 2 hex; in "#${r}${g}${b}ff"; }