Add lib.mod: integer modulus

Changed files
+10
lib
+10
lib/trivial.nix
···
min = x: y: if x < y then x else y;
max = x: y: if x > y then x else y;
/* Reads a JSON file. */
importJSON = path:
builtins.fromJSON (builtins.readFile path);
···
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);