Hostname: page-component-8448b6f56d-wq2xx Total loading time: 0 Render date: 2024-04-24T02:11:00.160Z 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, UKjeremy.gibbons@comlab.ox.ac.uk, richard.bird@comlab.ox.ac.uk
DAVID LESTER
Affiliation:
University of Manchester, Manchester, UKdlester@cs.man.ac.uk
RICHARD BIRD
Affiliation:
University of Oxford, Parks Road, Oxford, UKjeremy.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.