Some binary tree operations using nixla
yeah, fun
$ nixla-nix btree-7244c4a.nix '(a b c)'
[ "(" "a" "b" "c" ")" ]
$ nixla-nix btree-74f7f64.nix '(a b c)'
{ data = "a"; left = "b"; right = "c"; }
$ nixla btree-f9c2dae.nix '(a (b 1 2) (c 3 (d (e 7 8) 6)))'
a
b
1
2
c
3
d
e
7
8
6
$ nixla btree-deb6d86.nix '(a (b 1 2) (c 3 (d (e 7 8) 6)))'
a
c
d
6
e
8
7
3
b
2
1
# main-b0ed48a.nix
...
tree_dfs_preorder = tree:
if !isAttrs tree then
[tree]
else
[tree.data] ++
tree_dfs_preorder tree.left ++
tree_dfs_preorder tree.right
;
...
$ nixla-nix main-b0ed48a.nix '(a (b 1 2) (c 3 (d (e 7 8) 6)))'
[ "a" "b" "1" "2" "c" "3" "d" "e" "7" "8" "6" ]