lib.hexchars: init
This commit is contained in:
parent
377840226c
commit
f802eaf784
@ -45,6 +45,8 @@ let
|
|||||||
genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2;
|
genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2;
|
||||||
genid_uint32 = import ./genid.nix { inherit lib; };
|
genid_uint32 = import ./genid.nix { inherit lib; };
|
||||||
|
|
||||||
|
hexchars = stringToCharacters "0123456789abcdef";
|
||||||
|
|
||||||
lpad = n: c: s:
|
lpad = n: c: s:
|
||||||
if lib.stringLength s < n
|
if lib.stringLength s < n
|
||||||
then lib.lpad n c (c + s)
|
then lib.lpad n c (c + s)
|
||||||
|
@ -32,6 +32,5 @@ let out = genid;
|
|||||||
hexint = x: hexvals.${toLower x};
|
hexint = x: hexvals.${toLower x};
|
||||||
|
|
||||||
# :: attrset char uint4
|
# :: attrset char uint4
|
||||||
hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; })
|
hexvals = listToAttrs (imap (i: c: { name = c; value = i - 1; }) hexchars);
|
||||||
(stringToCharacters "0123456789abcdef"));
|
|
||||||
in out
|
in out
|
||||||
|
Loading…
Reference in New Issue
Block a user