mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 13:45:58 +01:00
lib/lists: init; add listContainsValue
Helps us validate lists that contain a bunch of values and see if it contains a desired list of values
This commit is contained in:
parent
7fd653b4d8
commit
b614dc6b41
2 changed files with 35 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
|||
binds = import ./binds.nix {inherit lib;};
|
||||
dag = import ./dag.nix {inherit lib;};
|
||||
languages = import ./languages.nix {inherit lib;};
|
||||
lists = import ./lists.nix {inherit lib;};
|
||||
lua = import ./lua.nix {inherit lib;};
|
||||
vim = import ./vim.nix;
|
||||
}
|
||||
|
|
34
lib/lists.nix
Normal file
34
lib/lists.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{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.
|
||||
|
||||
Returns:
|
||||
True if all values are present in the list, otherwise False.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
listContainsValues { list = [1 2 3]; values = [2 3]; }
|
||||
=> True
|
||||
|
||||
listContainsValues { list = [1 2 3]; values = [2 4]; }
|
||||
=> False
|
||||
```
|
||||
*/
|
||||
listContainsValues = {
|
||||
list,
|
||||
values,
|
||||
}: let
|
||||
# Check if all values are present in the list
|
||||
containsValue = value: elem value list;
|
||||
in
|
||||
all containsValue values;
|
||||
}
|
Loading…
Reference in a new issue