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.
|
# open a can of worms about implementing this with stringy types.
|
||||||
fromDec = decimal:
|
fromDec = decimal:
|
||||||
let
|
let
|
||||||
iter = product: value:
|
digits = pkgs.lib.toBaseDigits base decimal;
|
||||||
let
|
|
||||||
quotient = value / base;
|
|
||||||
remainder = value - (base * quotient);
|
|
||||||
baseDigit = glyphSet.${builtins.toString remainder} + product;
|
|
||||||
in
|
in
|
||||||
if quotient <= 0
|
pkgs.lib.concatMapStrings (d: glyphSet.${builtins.toString d}) digits;
|
||||||
then baseDigit
|
|
||||||
else iter baseDigit quotient;
|
|
||||||
in
|
|
||||||
iter "" decimal;
|
|
||||||
|
|
||||||
toDec = digit:
|
toDec = digit:
|
||||||
let
|
let
|
||||||
|
Loading…
Reference in New Issue
Block a user