nix-helpers: ab720995d9ff2c32c9b6f134d1fc1945d6351f0d
1: { die, getType }:
2:
3: with builtins;
4: with {
5: # Is xs a sublist of ys?
6: go = xs: ys:
7: assert isList xs || die {
8: inherit xs;
9: error = "First arg of subset must be list";
10: type = getType xs;
11: };
12: assert isList ys || die {
13: inherit ys;
14: error = "Second arg of subset must be list";
15: type = getType ys;
16: };
17: all (x: elem x ys) xs;
18: };
19: assert go [ ] [ ];
20: assert go [ ] [ 1 2 3 ];
21: assert go [ 2 1 ] [ 1 2 3 ];
22: assert !(go [ 2 1 ] [ ]);
23: assert !(go [ 2 4 ] [ 1 2 3 ]);
24: go
Generated by git2html.