Functional Pearl: Drawing Trees

  • Andrew Kennedy

Journal of Functional Programming | , Vol 6: pp. 527-534

This article describes the application of functional programming techniques to a problem previously studied by imperative programmers, that of drawing general trees automatically. We first consider the nature of the problem and the ideas behind its solution (due to Radack), independent of programming language implementation. We then describe a Standard ML program which reflects the structure of the abstract solution much better than an imperative language implementation. We conclude with an informal discussion on the correctness of the implementation and some changes which improve the algorithm’s worst-case time complexity.