summary refs log tree commit diff
path: root/lib/default.nix
diff options
context:
space:
mode:
authorBas van Dijk <v.dijk.bas@gmail.com>2020-04-20 12:00:23 +0200
committerBas van Dijk <v.dijk.bas@gmail.com>2020-07-20 13:09:26 +0200
commit00022fbeda385d7b6ae2eee44f07eecfc6d92015 (patch)
treeb542e068d7d85058445cadd1e495c349d6eb4ad3 /lib/default.nix
parentd0c12dc612bef680d129df40cbe7d80981a1e51c (diff)
downloadnixpkgs-00022fbeda385d7b6ae2eee44f07eecfc6d92015.tar
nixpkgs-00022fbeda385d7b6ae2eee44f07eecfc6d92015.tar.gz
nixpkgs-00022fbeda385d7b6ae2eee44f07eecfc6d92015.tar.bz2
nixpkgs-00022fbeda385d7b6ae2eee44f07eecfc6d92015.tar.lz
nixpkgs-00022fbeda385d7b6ae2eee44f07eecfc6d92015.tar.xz
nixpkgs-00022fbeda385d7b6ae2eee44f07eecfc6d92015.tar.zst
nixpkgs-00022fbeda385d7b6ae2eee44f07eecfc6d92015.zip
lib: add the toHex and toBase utility functions
`toHex` converts the given positive integer to a string of the hexadecimal
representation of that integer. For example:

```
toHex 0 => "0"

toHex 16 => "10"

toHex 250 => "FA"
```

`toBase base i` converts the positive integer `i` to a list of it
digits in the given `base`. For example:

```
toBase 10 123 => [ 1 2 3 ]

toBase 2 6 => [ 1 1 0 ]

toBase 16 250 => [ 15 10 ]
```
Diffstat (limited to 'lib/default.nix')
-rw-r--r--lib/default.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 7387e9d9f1f..a5c768ff407 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -67,7 +67,7 @@ let
     inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
       bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
       importJSON warn info showWarnings nixpkgsVersion version mod compare
-      splitByAndCompare functionArgs setFunctionArgs isFunction;
+      splitByAndCompare functionArgs setFunctionArgs isFunction toHex toBase;
     inherit (fixedPoints) fix fix' converge extends composeExtensions
       makeExtensible makeExtensibleWithCustomName;
     inherit (attrsets) attrByPath hasAttrByPath setAttrByPath