minor: std

This commit is contained in:
Emile Clark-Boman 2025-12-18 11:22:23 +10:00
parent 5b32197977
commit f57e6f47d0
2 changed files with 11 additions and 8 deletions

View file

@ -93,16 +93,17 @@ in rec {
mapAttrsRecursive = f: set: mapAttrsRecursiveCond (as: true) f set; mapAttrsRecursive = f: set: mapAttrsRecursiveCond (as: true) f set;
# form: attrValueAt :: xs -> path -> value # form: attrValueAt :: list string -> set -> Maybe Any
# given path as a list of strings, return that value of an # given path as a list of strings, return that value of an
# attribute set at that path # attribute set at that path
attrValueAt = let attrValueAt = path: xs:
value = foldl (l: r: foldl (left: right:
if builtins.isAttrs l && builtins.hasAttr r l if builtins.isAttrs left && builtins.hasAttr right left
then l.${r} then left.${right}
else null); else null)
in xs
nullableToMaybe value; path
|> nullableToMaybe;
mergeAttrsList = list: let mergeAttrsList = list: let
# `binaryMerge start end` merges the elements at indices `index` of `list` such that `start <= index < end` # `binaryMerge start end` merges the elements at indices `index` of `list` such that `start <= index < end`

View file

@ -51,4 +51,6 @@
if index == null if index == null
then default then default
else builtins.elemAt list index; else builtins.elemAt list index;
zipLists = zipListsWith (fst: snd: {inherit fst snd;});
} }