Hostname: page-component-cd9895bd7-gxg78 Total loading time: 0 Render date: 2024-12-26T06:39:16.219Z Has data issue: false hasContentIssue false

FUNCTIONAL PEARL: Enumerating the rationals

Published online by Cambridge University Press:  25 October 2016

JEREMY GIBBONS
Affiliation:
University of Oxford, Parks Road, Oxford, UK jeremy.gibbons@comlab.ox.ac.uk, richard.bird@comlab.ox.ac.uk
DAVID LESTER
Affiliation:
University of Manchester, Manchester, UK dlester@cs.man.ac.uk
RICHARD BIRD
Affiliation:
University of Oxford, Parks Road, Oxford, UK jeremy.gibbons@comlab.ox.ac.uk, richard.bird@comlab.ox.ac.uk
Rights & Permissions [Opens in a new window]

Extract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Every lazy functional programmer knows about the following approach to enumerating the positive rationals: generate a two-dimensional matrix (an infinite list of infinite lists), then traverse its finite diagonals (an infinite list of finite lists).

Type
Functional Pearls
Copyright
2006 Cambridge University Press
Submit a response

Discussions

No Discussions have been published for this article.