mirror of
https://github.com/bikini/patchwork
synced 2026-06-27 08:08:41 +00:00
26 lines
532 B
Python
26 lines
532 B
Python
from __future__ import annotations
|
|
|
|
|
|
class Node:
|
|
def __init__(self, value: int, child: Node | None = None):
|
|
self.value = value
|
|
self.child = child
|
|
|
|
|
|
def flatten(node: Node | None) -> list[int]:
|
|
values: list[int] = []
|
|
while node is not None:
|
|
values.append(node.value)
|
|
node = node.child
|
|
return values
|
|
|
|
|
|
def run() -> None:
|
|
chain = Node(1, Node(2, Node(3)))
|
|
print('annotations:', flatten(chain))
|
|
print('future:', flatten.__annotations__)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run()
|