diff --git a/list.cpp b/list.cpp index 83e7068..df8cc13 100644 --- a/list.cpp +++ b/list.cpp @@ -54,6 +54,15 @@ List *reverse(List *lst, List *prev = nullptr) return reverse(next, lst); } +template +void map(List *lst, U (*f)(T)) +{ + if (!lst) + return; + lst->value = f(lst->value); + map(lst->next, f); +} + template std::ostream& operator<<(std::ostream& ostream, const List *lst) {