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

Function contains_match

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

Source from the content-addressed store, hash-verified

205
206print("Example 14")
207def contains_match(tree, value):
208 match tree:
209 case pivot, left, _ if value < pivot:
210 return contains_match(left, value)
211 case pivot, _, right if value > pivot:
212 return contains_match(right, value)
213 case (pivot, _, _) | pivot:
214 return pivot == value
215
216
217assert contains_match(my_tree, 9)

Callers 1

item_009.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected