Lines Matching refs:ls
31 def binary_search(ls, v): argument
42 if not ls:
48 if v <= ls[0]:
55 hi = len(ls)
58 if v > ls[mid]:
78 def is_sorted(ls): argument
80 for i in range(len(ls) - 1):
81 if ls[i] > ls[i + 1]:
99 @given(ls=SortedLists, v=Values)
100 def test_insert_is_sorted(ls, v): argument
104 ls.insert(binary_search(ls, v), v)
105 assert is_sorted(ls)
108 @given(ls=SortedLists, v=Values)
109 def test_is_minimal(ls, v): argument
112 for i in range(binary_search(ls, v)):
113 ls2 = list(ls)
118 @given(ls=SortedLists, v=Values)
119 def test_inserts_into_same_place_twice(ls, v): argument
133 i = binary_search(ls, v)
134 ls.insert(i, v)
135 assert binary_search(ls, v) == i