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

Function contains_match_class

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

Source from the content-addressed store, hash-verified

258
259print("Example 18")
260def contains_match_class(tree, value):
261 match tree:
262 case Node(value=pivot, left=left) if value < pivot:
263 return contains_match_class(left, value)
264 case Node(value=pivot, right=right) if value > pivot:
265 return contains_match_class(right, value)
266 case Node(value=pivot) | pivot:
267 return pivot == value
268
269
270assert contains_match_class(obj_tree, 9)

Callers 1

item_009.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected