Skip to main content Accessibility help

Functional Pearls: Drawing trees

  • Andrew J. Kennedy (a1)

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.

Hide All
Bird, R. and Wadler, P. (1988) Introduction to Functional Programming. Prentice Hall.
Gibbons, J. (1991) Algebras for Tree Algorithms. DPhil thesis, Oxford University Computing Laboratory.
Gibbons, J. (1996) Deriving tidy drawings of trees. J. Functional Programming. This issue.
Milner, R., Tofte, M. and Harper, R. (1989) The Definition of Standard ML. MIT Press.
Paulson, L. C. (1991) ML for the Working Programmer. Cambridge University Press.
Radack, G. M. (1988) Tidy drawing of M-ary trees. Technical Report CES-88-24, Department of Computer Engineering and Science, Case Western Reserve University, Cleveland, OH, November.
Reingold, E. M. and Tilford, J. S. (1981) Tidier drawings of trees. IEEE Trans. Software Engineering, 7(2):223228, March.
Vaucher, J. G. (1980) Pretty-printing of trees. Software—Practice and Experience, 10:553561.
Walker, J. Q. II (1990) A node-positioning algorithm for general trees. Software—Practice and Experience, 20(7):685705, July.
Wetherell, C. and Shannon, A. (1979) Tidy drawings of trees. IEEE Trans. Software Engineering, 5(5):514520, September.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *


Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

Functional Pearls: Drawing trees

  • Andrew J. Kennedy (a1)
Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *