lib.lists.reverseList: avoid subtraction

This commit is contained in:
Eman Resu
2026-06-24 18:30:03 -04:00
parent 4e2f331f87
commit 4b623fa2b8
+3 -2
View File
@@ -1125,9 +1125,10 @@ rec {
reverseList =
xs:
let
l = length xs;
# subtract one to save an __sub call on every element
lastIndex = length xs - 1;
in
genList (n: elemAt xs (l - n - 1)) l;
genList (n: elemAt xs (lastIndex - n)) (lastIndex + 1);
/**
Depth-First Search (DFS) for lists `list != []`.