This commit is contained in:
Oleksandr Vyshniakov 2025-04-17 13:41:21 +02:00
parent 0de5cde8b8
commit 79818d918a

View File

@ -107,6 +107,22 @@ return acc;
list_element_t foldr_list(list_t *lst, list_element_t init,
list_element_t (*folder)(list_element_t, list_element_t)) {
list_element_t acc = init;
if (lst && folder) {
for (size_t i = lst->length; i > 0; --i) {
acc = folder(lst->elements[i - 1], acc);
}
}
return acc;
}
list_t *reverse_list(list_t *lst) { list_t *reverse_list(list_t *lst) {
if (!lst) return NULL; if (!lst) return NULL;