mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-24 03:43:53 +03:00
moved catAttrs, attrVals into attrsets.nix, adding attrValues
svn path=/nixpkgs/trunk/; revision=14425
This commit is contained in:
parent
be3a9f2346
commit
5ddfa7ed64
@ -1,6 +1,9 @@
|
||||
# Operations on attribute sets.
|
||||
|
||||
with { inherit (builtins) head tail; };
|
||||
with {
|
||||
inherit (builtins) head tail;
|
||||
inherit (import ./default.nix) fold;
|
||||
};
|
||||
|
||||
rec {
|
||||
inherit (builtins) attrNames listToAttrs hasAttr isAttrs;
|
||||
@ -18,5 +21,14 @@ rec {
|
||||
then getAttr (tail attrPath) default (builtins.getAttr attr e)
|
||||
else default;
|
||||
|
||||
# ordered by name
|
||||
attrValues = attrs: attrVals (__attrNames attrs) attrs;
|
||||
|
||||
attrVals = nameList : attrSet :
|
||||
map (x: builtins.getAttr x attrSet) nameList;
|
||||
|
||||
# iterates over a list of attributes collecting the attribute attr if it exists
|
||||
catAttrs = attr : l : fold ( s : l : if (hasAttr attr s) then [(builtins.getAttr attr s)] ++ l else l) [] l;
|
||||
|
||||
|
||||
}
|
@ -277,12 +277,6 @@ rec {
|
||||
setAttrMerge = name : default : attrs : f :
|
||||
setAttr attrs name (f (maybeAttr name default attrs));
|
||||
|
||||
# iterates over a list of attributes collecting the attribute attr if it exists
|
||||
catAttrs = attr : l : fold ( s : l : if (hasAttr attr s) then [(builtins.getAttr attr s)] ++ l else l) [] l;
|
||||
|
||||
attrVals = nameList : attrSet :
|
||||
map (x: builtins.getAttr x attrSet) nameList;
|
||||
|
||||
# Using f = a : b = b the result is similar to //
|
||||
# merge attributes with custom function handling the case that the attribute
|
||||
# exists in both sets
|
||||
|
Loading…
Reference in New Issue
Block a user