summaryrefslogtreecommitdiffstats
path: root/lib/trivial.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 9ee0549fc0fb..a57cf30d171c 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -70,6 +70,16 @@ rec {
min = x: y: if x < y then x else y;
max = x: y: if x > y then x else y;
+ /* Integer modulus
+
+ Example:
+ mod 11 10
+ => 1
+ mod 1 10
+ => 1
+ */
+ mod = base: int: base - (int * (builtins.div base int));
+
/* Reads a JSON file. */
importJSON = path:
builtins.fromJSON (builtins.readFile path);