ft_lstmap
Subject
FT_LSTMAP (simplified)
NAME
    ft_lstmap -- creates a new list resulting from the application of f to each element
SYNOPSIS
    t_list *ft_lstmap(t_list *lst, void (*f)(void *), void (*del)(void *));
DESCRIPTION
    Iterate over the list 'lst' and apply the function 'f' to the content of each elements. Create a new list resulting of the successive applications of 'f'. The function 'del' is used to destroy the content of an element if necessary.
PARAMETERS
    lst: pointer address to one element
    f: the address of the function to apply
    del: the address of the function that can delete an element's content
RETURN VALUES
    None
AUTHORIZED EXTERNAL FUNCTIONS
    NoneUnderstandable explanation
This functions works similarly as the ft_lstiter function, but it creates a new list resulting of the successive applications of f on each element's content.
Hints
/* check if lst or f or del is NULL */
/* loop over lst */
    /* create a new element */
    /* if new elem is null, clear the new list */
/* add the new element to the back of the list */
/* finally, return the new list */Commented solution
Last updated
Was this helpful?