libft
ft_lstmap.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* ft_lstmap.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2019/09/05 16:53:17 by unite #+# #+# */
10 /* Updated: 2020/07/16 03:01:34 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "libft.h"
15 
23 t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
24 {
25  t_list *new;
26  t_list *tmp;
27 
28  if (!lst)
29  return (NULL);
30  tmp = f(lst);
31  new = tmp;
32  while (lst->next)
33  {
34  lst = lst->next;
35  tmp->next = f(lst);
36  tmp = tmp->next;
37  }
38  return (new);
39 }
ft_lstmap
t_list * ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
Definition: ft_lstmap.c:23
s_list
A link in a multi-purpose linked list.
Definition: libft.h:34
s_list::next
struct s_list * next
The next link’s address or NULL if it’s the last link.
Definition: libft.h:38
libft.h