mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/util: add groupListBySize
Splits up a list into many sub-lists based on the given max-size. e.g. ```nix groupListBySize 2 [ 1 2 3 4 5 ] => [ [ 1 2 ] [ 3 4 ] [ 5 ] ] ```
This commit is contained in:
parent
693e749edb
commit
8f99c3953c
3 changed files with 61 additions and 0 deletions
|
@ -333,6 +333,47 @@ let
|
|||
"MIxEd"
|
||||
];
|
||||
};
|
||||
|
||||
testGroupListBySize = {
|
||||
expr = {
|
||||
empty = helpers.groupListBySize 5 [ ];
|
||||
"5/5" = helpers.groupListBySize 5 (lib.genList lib.id 5);
|
||||
"13/5" = helpers.groupListBySize 5 (lib.genList lib.id 13);
|
||||
};
|
||||
expected = {
|
||||
empty = [ ];
|
||||
"5/5" = [
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
]
|
||||
];
|
||||
"13/5" = [
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
]
|
||||
[
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
]
|
||||
[
|
||||
10
|
||||
11
|
||||
12
|
||||
]
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
if results == [ ] then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue