Add 15.nix

This commit is contained in:
NaiJi ✨ 2022-04-14 10:15:52 +00:00
parent dd206c75f1
commit ce962efde7
1 changed files with 18 additions and 0 deletions

18
15.nix Normal file
View File

@ -0,0 +1,18 @@
with import <nixpkgs> { };
with stdenv.lib;
let
attr = {a="a"; b = 1; c = true;};
s = "b";
in
{
#replace all X, everything should evaluate to true
ex0 = isAttrs attr;
ex1 = attr.a == "a";
ex2 = attr.${s} == 1;
ex3 = attrVals ["c" "b"] attr == [ true 1 ];
ex4 = attrValues attr == [ "a" 1 true ];
ex5 = builtins.intersectAttrs attr {a="b"; d=234; c="";}
== { a = "b"; c = "";};
ex6 = removeAttrs attr ["b" "c"] == { a="a"; };
ex7 = ! attr ? a == false;
}