lib.lists.takeEnd: rewrite to not call sublist

This commit is contained in:
Eman Resu
2026-06-24 18:29:20 -04:00
parent 3621649b19
commit bb3308e01e
+7 -1
View File
@@ -1547,7 +1547,13 @@ rec {
:::
*/
takeEnd = n: xs: drop (max 0 (length xs - n)) xs;
takeEnd =
count: list:
let
len = length list;
start = if count > len then 0 else len - count;
in
genList (i: elemAt list (start + i)) (if start > len then 0 else len - start);
/**
Remove the first (at most) N elements of a list.