Add lib.mod: integer modulus

wip/yesman
Domen Kožar 7 years ago
parent 9fd315a62f
commit 97a4088d33
No known key found for this signature in database
GPG Key ID: C2FFBCAFD2C24246
  1. 10
      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);

Loading…
Cancel
Save