A problem that has frequently come up in my career is I have some kind of data structure (perhaps an s-expression) and I want to print it in a human readable form complete with reasonable indentation choices.
Is there a book or blog entry that describes how to do this elegantly? I am interested in the algorithm more than a specific library.