Journal of Functional Programming



Functional Pearls

FUNCTIONAL PEARL: Enumerating the rationals


JEREMY GIBBONS a1, DAVID LESTER a2 and RICHARD BIRD a1
a1 University of Oxford, Parks Road, Oxford, UK jeremy.gibbons@comlab.ox.ac.uk, richard.bird@comlab.ox.ac.uk
a2 University of Manchester, Manchester, UK dlester@cs.man.ac.uk

Article author query
gibbons j   [Google Scholar] 
lester d   [Google Scholar] 
bird r   [Google Scholar] 
 

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).