submition2
This commit is contained in:
		
							parent
							
								
									5c9c57707f
								
							
						
					
					
						commit
						83f9a7726a
					
				| @ -1,5 +1,5 @@ | |||||||
| #include "list_ops.h" | #include "list_ops.h" | ||||||
| 
 | #include <string.h> | ||||||
| // constructs a new list
 | // constructs a new list
 | ||||||
| list_t *new_list(size_t length, list_element_t elements[]){ | list_t *new_list(size_t length, list_element_t elements[]){ | ||||||
| 	list_t* list = (list_t*)malloc(sizeof(list_t) + length * sizeof(list_element_t)); | 	list_t* list = (list_t*)malloc(sizeof(list_t) + length * sizeof(list_element_t)); | ||||||
| @ -10,18 +10,22 @@ list_t *new_list(size_t length, list_element_t elements[]){ | |||||||
| 
 | 
 | ||||||
| // append entries to a list and return the new list
 | // append entries to a list and return the new list
 | ||||||
| list_t *append_list(list_t *list1, list_t *list2){ | list_t *append_list(list_t *list1, list_t *list2){ | ||||||
|  | 	if(list1==list2){}; | ||||||
|   return NULL; |   return NULL; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // filter list returning only values that satisfy the filter function
 | // filter list returning only values that satisfy the filter function
 | ||||||
| list_t *filter_list(list_t *list, bool (*filter)(list_element_t)){ | list_t *filter_list(list_t *list, bool (*filter)(list_element_t)){ | ||||||
|  | 	if(filter){}; | ||||||
|  | 	if(list){}; | ||||||
|   return NULL; |   return NULL; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // returns the length of the list
 | // returns the length of the list
 | ||||||
| size_t length_list(list_t *list){ | size_t length_list(list_t *list){ | ||||||
|  | 	if(list){}; | ||||||
|   return 0; |   return 0; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @ -29,23 +33,26 @@ size_t length_list(list_t *list){ | |||||||
| // return a list of elements whose values equal the list value transformed by
 | // return a list of elements whose values equal the list value transformed by
 | ||||||
| // the mapping function
 | // the mapping function
 | ||||||
| list_t *map_list(list_t *list, list_element_t (*map)(list_element_t)){ | list_t *map_list(list_t *list, list_element_t (*map)(list_element_t)){ | ||||||
|  | 	if(map){}; | ||||||
|  | 	if(list){}; | ||||||
|   return NULL; |   return NULL; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // folds (reduces) the given list from the left with a function
 | // folds (reduces) the given list from the left with a function
 | ||||||
| list_element_t foldl_list(list_t *list, list_element_t initial, | list_element_t foldl_list(list_t *list, list_element_t initial,list_element_t (*foldl)(list_element_t,list_element_t)){ | ||||||
|                           list_element_t (*foldl)(list_element_t, | 
 | ||||||
|                                                   list_element_t)){ | 	if(list||foldl){}; | ||||||
|  | 	if(initial){}; | ||||||
|   list_element_t res=0; |   list_element_t res=0; | ||||||
|   return res; |   return res; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // folds (reduces) the given list from the right with a function
 | // folds (reduces) the given list from the right with a function
 | ||||||
| list_element_t foldr_list(list_t *list, list_element_t initial, | list_element_t foldr_list(list_t *list, list_element_t initial,list_element_t (*foldr)(list_element_t,list_element_t)){ | ||||||
|                           list_element_t (*foldr)(list_element_t, | 	if(list){}; | ||||||
|                                                   list_element_t)){ | 	if(initial||foldr){}; | ||||||
|   list_element_t res=0; |   list_element_t res=0; | ||||||
|   return res; |   return res; | ||||||
| 
 | 
 | ||||||
| @ -53,6 +60,7 @@ list_element_t foldr_list(list_t *list, list_element_t initial, | |||||||
| 
 | 
 | ||||||
| // reverse the elements of the list
 | // reverse the elements of the list
 | ||||||
| list_t *reverse_list(list_t *list){ | list_t *reverse_list(list_t *list){ | ||||||
|  | 	if(list){}; | ||||||
|   return NULL; |   return NULL; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user