-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstmap.c
33 lines (30 loc) · 1.2 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
33
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_lstmap.c :+: :+: */
/* +:+ */
/* By: splattje <splattje@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2023/10/13 10:29:02 by splattje #+# #+# */
/* Updated: 2023/10/25 09:23:18 by splattje ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
{
t_list *output;
t_list *temp;
output = 0;
while (lst)
{
temp = ft_lstnew(f(lst->content));
if (!temp)
{
ft_lstclear(&output, del);
return (0);
}
ft_lstadd_back(&output, temp);
lst = lst->next;
}
return (output);
}