Projet de l'école 42 : Libft
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

3 years ago
/* ************************************************************************** */
/* */
/* ::: :::::::: */
3 years ago
/* ft_first.c :+: :+: :+: */
3 years ago
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
3 years ago
/* Created: 2022/03/25 09:06:44 by narnaud #+# #+# */
/* Updated: 2022/03/25 13:26:04 by narnaud ### ########.fr */
3 years ago
/* */
/* ************************************************************************** */
#include "../libft.h"
3 years ago
size_t ft_ilst_first(t_i_slist *lst, int (*fct)(int a, int b))
3 years ago
{
3 years ago
int previous;
size_t i;
i = 1;
3 years ago
if (!lst)
3 years ago
return (0);
while (lst)
{
previous = lst->nb;
3 years ago
lst = lst->next;
3 years ago
if (lst && fct(previous, lst->nb))
return (i);
i++;
}
return (-1);
3 years ago
}