Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tree(val x: Int, val left: Tree? = null, val right: Tree? = null)
- fun order(T: Tree?) = sequence {
- if (T == null) return@sequence
- yieldAll(order(T.left))
- yield(T.x)
- yieldAll(order(T.right))
- }
- fun main() = println(order(Tree(2, Tree(1), Tree(3))).toList())
Advertisement
Add Comment
Please, Sign In to add comment