fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 18: Depth-first traversing of a tree
Idiom # 18: Depth-first traversing of a tree
See
programming-idioms.org
:
Code
node(T type, val T, children Sequence (node T)) is traverse (f T -> unit) unit => f val for child in children do child.traverse f
What are effects?
Running Example
ex18 is node(T type, val T, children Sequence (node T)) is traverse (f T -> unit) unit => f val for child in children do child.traverse f blatt(val String) => node val (list (node String)).empty t := node "lion" [blatt "cougar", blatt "elephant", node "hornet" [blatt "bee", blatt "ant"], blatt "beatle2"] t.traverse (x -> say x)
What are effects?
last changed: 2024-07-01
next: Idiom # 19: Reverse a list