MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / contains

Function contains

example_code/item_009.py:184–195  ·  view source on GitHub ↗
(tree, value)

Source from the content-addressed store, hash-verified

182
183print("Example 12")
184def contains(tree, value):
185 if not isinstance(tree, tuple):
186 return tree == value
187
188 pivot, left, right = tree
189
190 if value < pivot:
191 return contains(left, value)
192 elif value > pivot:
193 return contains(right, value)
194 else:
195 return value == pivot
196
197
198print("Example 13")

Callers 1

item_009.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected