Add '33.nix'
This commit is contained in:
parent
8c8f645473
commit
07f9557006
|
@ -0,0 +1,11 @@
|
||||||
|
with import <nixpkgs> { };
|
||||||
|
let
|
||||||
|
list = [["a"] ["b"] ["c"]];
|
||||||
|
|
||||||
|
attrList = [{a = 1;} {b = 0;} {a = 2;}];
|
||||||
|
catAttrs = atr: l: lib.fold (val: _l: if (builtins.hasAttr atr val) then [ (val.${atr}) ] ++ _l else _l) [] l;
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
example = builtins.concatLists list; #is [ "a" "b" "c" ]
|
||||||
|
result = catAttrs "a" attrList; #should be [1 2]
|
||||||
|
}
|
Loading…
Reference in New Issue