|  | @@ -22,8 +22,16 @@ def compute_new(func_list, *args):
 | 
											
												
													
														|  |      return lst
 |  |      return lst
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -def filter_list(f: Callable, lst: list):
 |  | 
 | 
											
												
													
														|  | -    pass
 |  | 
 | 
											
												
													
														|  | 
 |  | +# def filter_list(f: Callable, lst: list):
 | 
											
												
													
														|  | 
 |  | +def filter_list(f, lst):
 | 
											
												
													
														|  | 
 |  | +    return [value for value in lst if f(value)]
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +def filter_collection(f, collection):
 | 
											
												
													
														|  | 
 |  | +    lst = [value for value in collection if f(value)]
 | 
											
												
													
														|  | 
 |  | +    if isinstance(collection, str):
 | 
											
												
													
														|  | 
 |  | +        return ''.join(lst)
 | 
											
												
													
														|  | 
 |  | +    return type(collection)(lst)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  """Для теста"""
 |  |  """Для теста"""
 | 
											
										
											
												
													
														|  | @@ -36,11 +44,26 @@ def inc(num):
 | 
											
												
													
														|  |  def dec(num):
 |  |  def dec(num):
 | 
											
												
													
														|  |      return num - 1
 |  |      return num - 1
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +def is_even(num):
 | 
											
												
													
														|  | 
 |  | +    return num % 2 == 0
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  def main():
 |  |  def main():
 | 
											
												
													
														|  | -    print(compute([inc, dec, square], 10, 20, 30, 40))
 |  | 
 | 
											
												
													
														|  | -    print(compute_new([inc, square, dec], 10, 20, 30, 40))
 |  | 
 | 
											
												
													
														|  | 
 |  | +    # print(compute([inc, dec, square], 10, 20, 30, 40))
 | 
											
												
													
														|  | 
 |  | +    # print(compute_new([inc, square, dec], 10, 20, 30, 40))
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    # numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
 | 
											
												
													
														|  | 
 |  | +    # even_numbers = filter_list(is_even, numbers) # берем только четные
 | 
											
												
													
														|  | 
 |  | +    # print(even_numbers)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
 | 
											
												
													
														|  | 
 |  | +    even_numbers = filter_collection(is_even, numbers)
 | 
											
												
													
														|  | 
 |  | +    print(even_numbers)
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    print(filter_collection(lambda x: x not in 'aeiou', 'I never heard those lyrics before'))
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  if __name__ == '__main__':
 |  |  if __name__ == '__main__':
 | 
											
												
													
														|  |      main()
 |  |      main()
 |