updated from Atlas

This commit is contained in:
Luciano Ramalho
2015-04-01 22:48:56 -03:00
parent aab93699a4
commit 573e1a94c4
109 changed files with 5 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
"""
>>> bisect_in([], 1)
False
>>> import array
>>> import random
>>> SIZE = 10
>>> my_array = array.array('l', range(0, SIZE, 2))
>>> random.seed(42)
>>> for i in range(SIZE):
... print(i, bisect_in(my_array, i))
0 True
1 False
2 True
3 False
4 True
5 False
6 True
7 False
8 True
9 False
"""
from bisect import bisect
def bisect_in(seq, item):
pos = bisect(seq, item)
return seq[pos-1] == item if seq else False