31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_map.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/06/23 10:39:56 by whaffman #+# #+# */
|
|
/* Updated: 2024/06/23 10:49:46 by whaffman ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
|
|
int *ft_map(int *tab, int length, int(*f)(int))
|
|
{
|
|
int i;
|
|
int *result;
|
|
|
|
i = 0;
|
|
result = (int *) malloc(length * sizeof(int *));
|
|
if(result)
|
|
{
|
|
while (i < n)
|
|
{
|
|
result[i] = f(tab[i]);
|
|
}
|
|
}
|
|
return (result);
|
|
}
|