mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
bahaghari/lib: simplify fromDec
implementation
This commit is contained in:
parent
e5083302b2
commit
9fde40828b
@ -129,17 +129,9 @@ rec {
|
||||
# open a can of worms about implementing this with stringy types.
|
||||
fromDec = decimal:
|
||||
let
|
||||
iter = product: value:
|
||||
let
|
||||
quotient = value / base;
|
||||
remainder = value - (base * quotient);
|
||||
baseDigit = glyphSet.${builtins.toString remainder} + product;
|
||||
digits = pkgs.lib.toBaseDigits base decimal;
|
||||
in
|
||||
if quotient <= 0
|
||||
then baseDigit
|
||||
else iter baseDigit quotient;
|
||||
in
|
||||
iter "" decimal;
|
||||
pkgs.lib.concatMapStrings (d: glyphSet.${builtins.toString d}) digits;
|
||||
|
||||
toDec = digit:
|
||||
let
|
||||
|
Loading…
Reference in New Issue
Block a user