-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #996 from dsalaza4/main
feat(back): #995 new builtins
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
__nixpkgs__, | ||
sublist, | ||
... | ||
}: list: n: let | ||
lib = __nixpkgs__.lib; | ||
|
||
len = lib.lists.length list; | ||
div = len / n; | ||
mod = lib.trivial.mod len n; | ||
range = lib.lists.range 0 (n - 1); | ||
min = lib.trivial.min; | ||
startIndex = i: i * div + (min i mod); | ||
endIndex = i: (i + 1) * div + (min (i + 1) mod); | ||
in | ||
builtins.map (i: sublist list (startIndex i) (endIndex i)) range |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{__nixpkgs__, ...}: list: start: end: let | ||
lib = __nixpkgs__.lib; | ||
|
||
range = lib.lists.range start (end - 1); | ||
in | ||
builtins.map (lib.lists.elemAt list) range |