-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstmap.c
30 lines (27 loc) · 1.11 KB
/
ft_lstmap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rlechapt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/04/02 05:28:04 by rlechapt #+# #+# */
/* Updated: 2015/04/02 07:23:04 by rlechapt ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
{
t_list *new;
t_list *first;
if (!lst)
return (NULL);
new = f(lst);
first = new;
while (lst)
{
new->next = f(lst);
lst = lst->next;
}
return (first);
}