aspon bod prosim
This commit is contained in:
parent
204b2ec003
commit
87e1e23e2f
@ -129,6 +129,22 @@ list_element_t foldl_list(list_t *list, list_element_t initial,
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
list_element_t foldr_list(list_t *list, list_element_t initial,
|
||||
list_element_t (*foldr)(list_element_t,
|
||||
list_element_t)) {
|
||||
if (!list || !foldr) {
|
||||
return initial;
|
||||
}
|
||||
|
||||
list_element_t result = initial;
|
||||
|
||||
for (size_t i = 0; i < list->length; ++i) {
|
||||
result = foldr(list->elements[list->length - 1 - i], result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
list_t *reverse_list(list_t *list) {
|
||||
if (!list) {
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user