summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-03-03 03:06:30 +0100
committertv <tv@krebsco.de>2021-03-03 03:06:30 +0100
commitb1ac76de21e097b6026c6101aac060d57a29e216 (patch)
tree7e3552118b6f04adce0648ce54a51da84cb577c2
parent8da229e5f06325f7660b8b4bd848374379349f4e (diff)
lib: add compose
-rw-r--r--lib/default.nix4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 2efeec0..4190f8f 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -15,6 +15,10 @@ let
uri = import ./uri.nix { inherit lib; };
xml = import ./xml.nix { inherit lib; };
+ # compose a list of functions to be applied from left to right, i.e.
+ # compose :: [ (xm -> xn) ... (x1 -> x2) (x0 -> x1) ] -> x0 -> xn
+ compose = foldl' (f: g: x: f (g x)) id;
+
eq = x: y: x == y;
ne = x: y: x != y;
mod = x: y: x - y * (x / y);