Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. def head(list_function):
  2. return list_function[0]
  3.  
  4. def last(list_function):
  5. return list_function[len(list_function)-1]
  6.  
  7. def tail(list_function):
  8. new_list = []
  9. for index in range(1,len(list_function)):
  10. new_list += [list_function[index]]
  11. return new_list
  12.  
  13. def equal_lists(list_function1,list_function2):
  14.  
  15. for index in range(0,len(list_function1)):
  16. if list_function1[index] == list_function2[index] and len(list_function1) == len(list_function2):
  17. return True
  18.  
  19. else:
  20. return False
  21.  
  22. def count_item(search, items):
  23. count = 0
  24.  
  25. for item in items:
  26. if item == search:
  27. count += 1
  28.  
  29. return count
  30.  
  31. def take(n, items):
  32. result = []
  33.  
  34. for index in range(0, min(n, len(items))):
  35. result += [items[index]]
  36.  
  37. return result
  38.  
  39. def drop(n, items):
  40. result = []
  41.  
  42. for index in range(n, len(items)):
  43. result += [items[index]]
  44.  
  45. return result
  46.  
  47. def reverse(items):
  48. result = []
  49.  
  50. last_index = len(items) - 1
  51.  
  52. while last_index >= 0:
  53. result += [items[last_index]]
  54. last_index -= 1
  55.  
  56. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement