18 lines
378 B
Nix
18 lines
378 B
Nix
{
|
|
...
|
|
}:
|
|
rec {
|
|
# https://github.com/NixOS/nixpkgs/issues/41251#issuecomment-393660714
|
|
pow = base: exponent:
|
|
if exponent > 0 then
|
|
let
|
|
and1 = x: (x / 2) * 2 != x;
|
|
x = pow base (exponent / 2);
|
|
in
|
|
x * x * (if and1 exponent then base else 1)
|
|
else if exponent == 0 then
|
|
1
|
|
else
|
|
throw "undefined";
|
|
}
|