Add lib.mod: integer modulus

This commit is contained in:
Domen Kožar 2017-08-30 14:32:04 +02:00
parent 9fd315a62f
commit 97a4088d33
No known key found for this signature in database
GPG Key ID: C2FFBCAFD2C24246

View File

@ -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);