blob: 1dfce7881e24c190cb27d4b6cdfe461048835093 (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/09 09:03:57 by cacharle #+# #+# */
/* Updated: 2019/10/21 11:43:10 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
t_list *ft_lstmap(t_list *lst, void *(*f)(void *))
{
t_list *mapped;
if (lst == NULL || f == NULL)
return (NULL);
if ((mapped = ft_lstnew(lst->content)) == NULL)
return (NULL);
mapped->content = (*f)(mapped->content);
mapped->next = ft_lstmap(lst->next, f);
return (mapped);
}
|