diff options
Diffstat (limited to 'c12/ex15/ft_list_reverse_fun.c')
| -rw-r--r-- | c12/ex15/ft_list_reverse_fun.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/c12/ex15/ft_list_reverse_fun.c b/c12/ex15/ft_list_reverse_fun.c index e69de29..9ee845e 100644 --- a/c12/ex15/ft_list_reverse_fun.c +++ b/c12/ex15/ft_list_reverse_fun.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_list_reverse_fun.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/19 13:55:34 by cacharle #+# #+# */ +/* Updated: 2019/07/20 08:18:04 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +static t_list *reverse_rec(t_list *begin_list) +{ + if (!begin_list) + return begin_list; + if (!begin_list->next) + return begin_list; + ft_list_reverse_fun(begin_list->next); + begin_list->next->next = begin_list; + begin_list->next = NULL; +} + +void ft_list_reverse_fun(t_list *begin_list) +{ + begin_list = reverse_rec(begin_list); +} |
