given the problem from:
http://arunrocks.com/treeify_-_converting_tree_data_structures/
For a hobby project, I was faced with an interesting problem of converting a flat representation of a tree into a nested data structure. A flat representation of a tree looks like this:
0 0 1 1 2 3 2 1
Each number refers to the nesting level within a tree. After conversion to a nested structure, it should look as follows (square brackets is the Python syntax for a list):
[ 0, 0, [ 1, 1, [ 2, [ 3 ], 2], 1]]
How can I do this in Haskell?