/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_map.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/16 21:17:12 by cacharle #+# #+# */ /* Updated: 2019/07/18 11:00:42 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include int *ft_map(int *tab, int length, int (*f)(int)) { int i; int *mapped; if ((mapped = (int*)malloc(sizeof(int) * length)) == NULL) return (NULL); i = 0; while (i < length) { mapped[i] = (*f)(tab[i]); i++; } return (mapped); }