lib.hexchars: init

This commit is contained in:
tv 2023-02-05 00:47:55 +01:00
parent 377840226c
commit f802eaf784
2 changed files with 3 additions and 2 deletions

View File

@ -45,6 +45,8 @@ let
genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2;
genid_uint32 = import ./genid.nix { inherit lib; };
hexchars = stringToCharacters "0123456789abcdef";
lpad = n: c: s:
if lib.stringLength s < n
then lib.lpad n c (c + s)

View File

@ -32,6 +32,5 @@ let out = genid;
hexint = x: hexvals.${toLower x};
# :: attrset char uint4
hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; })
(stringToCharacters "0123456789abcdef"));
hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; }) hexchars);
in out