-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstmap.c
32 lines (29 loc) · 1.19 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
31
32
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ewilliam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 16:27:06 by ewilliam #+# #+# */
/* Updated: 2016/12/08 13:40:25 by ewilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
{
t_list *head;
t_list *head_curr;
if (!lst || !f)
return (NULL);
head_curr = f(lst);
head = head_curr;
lst = lst->next;
while (lst)
{
head_curr->next = f(lst);
head_curr = head_curr->next;
lst = lst->next;
}
return (head);
}