2024-07-21 14:18:23 -07:00
|
|
|
final: prev:
|
2024-08-19 06:21:38 -07:00
|
|
|
let
|
2024-08-24 19:51:44 -07:00
|
|
|
inherit (prev) isFunction mkMerge mkIf;
|
2024-08-19 06:21:38 -07:00
|
|
|
in
|
2024-06-28 07:48:26 -07:00
|
|
|
rec {
|
|
|
|
# Ternary operator
|
|
|
|
# Exaample:
|
|
|
|
# tern false 1 2 => 2
|
|
|
|
# tern true 1 2 => 1
|
|
|
|
tern = pred: x: y: if pred then x else y;
|
|
|
|
|
|
|
|
# Right-associate and chain following single-operand functions
|
|
|
|
# Example:
|
|
|
|
# right f g h 1 => f(g(h(1)))
|
|
|
|
right = f: g: tern (isFunction g)
|
|
|
|
(right (x: f (g (x))))
|
|
|
|
(f (g));
|
2024-08-24 19:51:44 -07:00
|
|
|
|
|
|
|
mkIfElse = predicate: yes: no: mkMerge [
|
|
|
|
(mkIf predicate yes)
|
|
|
|
(mkIf (!predicate) no)
|
|
|
|
];
|
2024-08-29 20:27:10 -07:00
|
|
|
|
|
|
|
zgitRepo = name: "https://git.zynh.me/Zynh0722/${name}.git";
|
2024-06-28 07:48:26 -07:00
|
|
|
}
|