-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_map_2d_int_array.c
36 lines (33 loc) · 1.32 KB
/
ft_map_2d_int_array.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_map_2d_int_array.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/08/07 23:49:32 by sgrindhe #+# #+# */
/* Updated: 2018/08/08 21:43:10 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_2d_int_array *ft_map_2d_int_array(t_2d_int_array *t_2darray, int (*f)(int))
{
t_2d_int_array *newarray;
unsigned int i;
unsigned int z;
i = 0;
newarray = ft_2d_int_array(t_2darray->width, t_2darray->height);
if (!newarray)
return (NULL);
while (i < t_2darray->width)
{
z = 0;
while (z < t_2darray->height)
{
newarray->two_dim_array[i][z] = f(t_2darray->two_dim_array[i][z]);
z++;
}
i++;
}
return (newarray);
}