summaryrefslogtreecommitdiffstats
path: root/lib/lists.nix
blob: f45997d83a697b60be2a3bb6b2dce36319ce30be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{lib}: let
  inherit (lib.lists) elem all;
in {
  /**
  Checks if all values are present in the list.

  # Type

  ```
  listContainsValues :: { list :: [a], values :: [a] } -> Bool
  ```

  # Arguments

  - `list`: A list of elements.
  - `values`: A list of values to check for presence in the list.

  # Example

  ```nix
  listContainsValues { list = [1 2 3]; values = [2 3]; }
  => true

  listContainsValues { list = [1 2 3]; values = [2 4]; }
  => false
  ```
  */
  listContainsValues = {
    list,
    values,
  }: let
    containsValue = value: elem value list;
  in
    all containsValue values;
}