File tree 13 files changed +277
-20
lines changed
13 files changed +277
-20
lines changed Original file line number Diff line number Diff line change 1
1
# 42
2
2
* DS_Store
3
- main.c
4
3
* .vscode
5
4
6
5
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_entropy.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 13:38:28 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //copies a list of ints
16
+
17
+ int * array_cpy (int * srclst , int n )
18
+ {
19
+ int * dstlst ;
20
+
21
+ dstlst = ft_calloc (n ++ , sizeof (int ));
22
+ if (!srclst && !dstlst && !(0 < n ))
23
+ return (NULL );
24
+ while (n -- )
25
+ dstlst [n ] = srclst [n ];
26
+ return (dstlst );
27
+ }
28
+
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_mean.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 13:37:37 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //finds the average value of a given list
16
+
17
+ void * ft_math_avrg (int * lst )
18
+ {
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_entropy.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 13:38:28 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //finds the "entropy" of a given list (see google doc)
16
+
17
+ void * ft_math_entropy (int * lst )
18
+ {
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_exp.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 15:22:52 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //finds the eth exponent of a given number (below ^32)
16
+
17
+ int * ft_math_exp (int n , int e )
18
+ {
19
+ int result ;
20
+
21
+ result = 1 ;
22
+ if (e < 31 )
23
+ {
24
+ while (e -- > 0 && n != 0 )
25
+ result *= n ;
26
+ return (result );
27
+ }
28
+ else
29
+ return (void ) ;
30
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_max.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 15:31:17 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //finds the greater number of a given list
16
+
17
+ int * ft_math_max (int * lst )
18
+ {
19
+ int result ;
20
+
21
+ if (lst );
22
+ {
23
+ result = * lst ;
24
+ while (lst ++ )
25
+ {
26
+ if (* lst > result )
27
+ result = * lst ;
28
+ }
29
+ return (result );
30
+ }
31
+ else
32
+ return (void );
33
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_mean.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 13:37:46 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //finds the average value of a given list
16
+
17
+ void * ft_math_avrg (int * lst )
18
+ {
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_med.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 13:37:00 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //finds the median number of a given list
16
+
17
+ void * ft_math_med (int * lst )
18
+ {
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_min.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 15:31:41 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //finds the lesser number of a given list
16
+
17
+ int * ft_math_min (int * lst )
18
+ {
19
+ int result ;
20
+
21
+ if (lst );
22
+ {
23
+ result = * lst ;
24
+ while (lst ++ )
25
+ {
26
+ if (* lst < result )
27
+ result = * lst ;
28
+ }
29
+ return (result );
30
+ }
31
+ else
32
+ return (void );
33
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_math_root.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2022/07/11 13:33:14 by llord #+# #+# */
9
+ /* Updated: 2022/07/11 13:34:48 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //takes the rth root of a given number
16
+
17
+ void * ft_math_root (int n , int r )
18
+ {
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ /* ************************************************************************** */
2
+ /* */
3
+ /* ::: :::::::: */
4
+ /* ft_free_array.c :+: :+: :+: */
5
+ /* +:+ +:+ +:+ */
6
+ /* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
+ /* +#+#+#+#+#+ +#+ */
8
+ /* Created: 2023/03/07 15:31:17 by llord #+# #+# */
9
+ /* Updated: 2023/03/07 15:39:09 by llord ### ########.fr */
10
+ /* */
11
+ /* ************************************************************************** */
12
+
13
+ #include "libft.h"
14
+
15
+ //takes a pointer's adress and frees whatever is there, setting it to NULL after
16
+ void ft_free_null (void * * ptr )
17
+ {
18
+ free (* ptr );
19
+ * ptr = NULL ;
20
+ }
21
+
22
+ //takes a array's adress and frees whatever is there, setting it all to NULL after
23
+ void ft_free_array (void * * * ptr )
24
+ {
25
+ int i ;
26
+
27
+ if (* ptr )
28
+ {
29
+ i = -1 ;
30
+ while (* ptr [++ i ])
31
+ ft_free_null (& ((* ptr )[i ]));
32
+ ft_free_null (ptr );
33
+ }
34
+ }
Original file line number Diff line number Diff line change 6
6
/* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* Created: 2022/01/31 13:35:19 by llord #+# #+# */
9
- /* Updated: 2022/04/12 09:59:03 by llord ### ########.fr */
9
+ /* Updated: 2022/10/21 12:45:00 by llord ### ########.fr */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
15
15
//creates a new string without the specified characters
16
16
//at the begining/end of the original string
17
17
18
- static int notin (char c , const char * set );
18
+ static int not_in_set (char c , const char * set )
19
+ {
20
+ int i ;
21
+
22
+ i = 0 ;
23
+ while (set [i ])
24
+ {
25
+ if (set [i ] == c )
26
+ return (0 );
27
+ i ++ ;
28
+ }
29
+ return (1 );
30
+ }
19
31
20
32
char * ft_strtrim (char const * s1 , char const * set )
21
33
{
@@ -26,25 +38,11 @@ char *ft_strtrim(char const *s1, char const *set)
26
38
if (!s1 || !set )
27
39
return (0 );
28
40
start = 0 ;
29
- while (!notin (s1 [start ], set ) && s1 [start ])
41
+ while (!not_in_set (s1 [start ], set ) && s1 [start ])
30
42
start ++ ;
31
43
end = ft_strlen (s1 );
32
- while (!notin (s1 [end - 1 ], set ) && start < end )
44
+ while (!not_in_set (s1 [end - 1 ], set ) && start < end )
33
45
end -- ;
34
46
s2 = (ft_substr (s1 , start , (size_t )(end - start )));
35
47
return (s2 );
36
48
}
37
-
38
- static int notin (char c , const char * set )
39
- {
40
- int i ;
41
-
42
- i = 0 ;
43
- while (set [i ])
44
- {
45
- if (set [i ] == c )
46
- return (0 );
47
- i ++ ;
48
- }
49
- return (1 );
50
- }
Original file line number Diff line number Diff line change 6
6
/* By: llord <llord@student.42.fr> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* Created: 2022/03/28 14:20:01 by llord #+# #+# */
9
- /* Updated: 2022/04/23 11:27:54 by llord ### ########.fr */
9
+ /* Updated: 2023/03/07 15:39:12 by llord ### ########.fr */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
@@ -43,6 +43,8 @@ void ft_lstclear(t_list **lst, void (*del)(void*));
43
43
void ft_lstiter (t_list * lst , void (* f )(void * ));
44
44
t_list * ft_lstmap (t_list * lst , void * (* f )(void * ), void (* del )(void * ));
45
45
46
+ void ft_free_null (void * * ptr );
47
+ void ft_free_array (void * * * ptr );
46
48
void * ft_bzero (void * s , size_t n );
47
49
void * ft_calloc (size_t count , size_t size );
48
50
void * ft_memset (void * b , int c , size_t len );
You can’t perform that action at this time.
0 commit comments