PYTHON   30

run all py

Guest on 5th August 2022 03:01:53 PM

  1. def run_all(fn_list, args_list):
  2.     results = []
  3.     for (fn,args) in zip(fn_list, args_list):
  4.         result = apply(fn, args)
  5.         results.append(result)
  6.     return results
  7.        
  8. # Test code
  9.  
  10. plus = lambda x,y: x + y
  11. mult = lambda x,y: x * y
  12. inv = lambda x: 1 / float(x)
  13.  
  14. print run_all([plus, mult, inv], [(2,3),(6,8),(13,)])

Raw Paste


Login or Register to edit or fork this paste. It's free.