Contest (!): In the language of your choice, write a program that will traverse the directory tree of a given directory and output a tree (i.e., an array of arrays) corresponding to it. Assume the directory is a predefined variable D. Smallest character count wins.
- You must use recursion
- See Rules
Note: Assume that there are no recursion depth limits. In other words, your code just needs to work for sufficiently small directory trees, and in principle for larger ones.
Directory tree is
dir1 ├── dir11 │ ├── file111 │ └── file112 ├── dir12 │ ├── file121 │ ├── file122 │ └── file123 ├── file11 ├── file12 └── file13
Output tree is
First code golf here so lemme know if I'm doing something wrong.
Have fun :)