mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-09-11 03:45:29 +03:00
21 lines
447 B
Plaintext
21 lines
447 B
Plaintext
from lib/types import (Bool, MyTree)
|
|
from lib import bool_xor
|
|
|
|
def tree_xor(tree):
|
|
fold tree:
|
|
case MyTree/node:
|
|
return bool_xor(tree.lft, tree.rgt);
|
|
case MyTree/leaf:
|
|
return tree.val;
|
|
|
|
main =
|
|
let depth = 10
|
|
let tree = bend n = 0 {
|
|
when (< n depth):
|
|
(MyTree/node (fork (+ n 1)) (fork (+ n 1)))
|
|
else:
|
|
if (% n 2) { (MyTree/leaf Bool/True) } else { (MyTree/leaf Bool/False) }
|
|
}
|
|
(tree_xor tree)
|
|
|