···6 inherit (lib.strings) toInt;
7 inherit (lib.trivial) compare min id warn pipe;
8 inherit (lib.attrsets) mapAttrs;
09in
10rec {
11···1496 drop =
1497 count:
1498 list: sublist count (length list) list;
000000000000000000000000000000000000000014991500 /**
1501 Whether the first list is a prefix of the second list.
···6 inherit (lib.strings) toInt;
7 inherit (lib.trivial) compare min id warn pipe;
8 inherit (lib.attrsets) mapAttrs;
9+ inherit (lib) max;
10in
11rec {
12···1497 drop =
1498 count:
1499 list: sublist count (length list) list;
1500+1501+ /**
1502+ Remove the last (at most) N elements of a list.
1503+1504+1505+ # Inputs
1506+1507+ `count`
1508+1509+ : Number of elements to drop
1510+1511+ `list`
1512+1513+ : Input list
1514+1515+ # Type
1516+1517+ ```
1518+ dropEnd :: Int -> [a] -> [a]
1519+ ```
1520+1521+ # Examples
1522+1523+ :::{.example}
1524+ ## `lib.lists.dropEnd` usage example
1525+1526+ ```nix
1527+ dropEnd 2 [ "a" "b" "c" "d" ]
1528+ => [ "a" "b" ]
1529+ dropEnd 2 [ ]
1530+ => [ ]
1531+ ```
1532+ :::
1533+1534+ */
1535+ dropEnd =
1536+ n: xs:
1537+ take
1538+ (max 0 (length xs - n))
1539+ xs;
15401541 /**
1542 Whether the first list is a prefix of the second list.