Started from buttom go to the sky
This commit is contained in:
parent
96215449bd
commit
f811e55dea
4781 changed files with 10121 additions and 1743 deletions
33
stdme/src/string/str_map.c
Normal file
33
stdme/src/string/str_map.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* str_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 18:26:00 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/12/09 14:52:34 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/string/str_clone.h"
|
||||
#include "me/string/str_map.h"
|
||||
|
||||
t_str str_map(t_const_str s, char (*f)(t_usize, char))
|
||||
{
|
||||
t_str out;
|
||||
t_usize idx;
|
||||
|
||||
if (f == NULL || s == NULL)
|
||||
return (NULL);
|
||||
out = str_clone((t_str)s);
|
||||
if (out == NULL)
|
||||
return (NULL);
|
||||
idx = 0;
|
||||
while (s[idx])
|
||||
{
|
||||
out[idx] = f(idx, s[idx]);
|
||||
idx++;
|
||||
}
|
||||
return (out);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue