28 lines
1.1 KiB
C
28 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_map.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/11/07 16:54:39 by gtertysh #+# #+# */
|
|
/* Updated: 2016/11/07 17:25:19 by gtertysh ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
|
|
int *ft_map(int *tab, int length, int (*f)(int))
|
|
{
|
|
int *arr;
|
|
int i;
|
|
|
|
i = 0;
|
|
arr = (int *)malloc(sizeof(int) * (length));
|
|
while (i < length)
|
|
{
|
|
arr[i] = f(tab[i]);
|
|
i++;
|
|
}
|
|
return (arr);
|
|
}
|