data Tree a = Node a (Tree a) (Tree a) | Tip
flatten :: Tree a -> [a]
flatten x = (flatten' x) []
flatten' :: Tree a -> [a] -> [a]
flatten' (Node x left right) l = (flatten' left (x:(flatten' right l)))
flatten' Tip l = l
main =
(Node 2 (Node 1 Tip Tip) (Node 4 (Node 3 Tip Tip) Tip))
ZGF0YSBUcmVlIGEgPSBOb2RlIGEgKFRyZWUgYSkgKFRyZWUgYSkgfCBUaXAKCmZsYXR0ZW4gOjogVHJlZSBhIC0+IFthXQpmbGF0dGVuIHggPSAoZmxhdHRlbicgeCkgW10KCmZsYXR0ZW4nIDo6IFRyZWUgYSAtPiBbYV0gLT4gW2FdCmZsYXR0ZW4nIChOb2RlIHggbGVmdCByaWdodCkgbCA9IChmbGF0dGVuJyBsZWZ0ICh4OihmbGF0dGVuJyByaWdodCBsKSkpCmZsYXR0ZW4nIFRpcCBsID0gbAoKbWFpbiA9IAogIHB1dFN0ckxuICQgc2hvdyAkIGZsYXR0ZW4gJCAKICAgIChOb2RlIDIgKE5vZGUgMSBUaXAgVGlwKSAoTm9kZSA0IChOb2RlIDMgVGlwIFRpcCkgVGlwKSk=