Infinite streams in Java

  • Authors:
  • Dominik Gruntz

  • Affiliations:
  • University of Applied Sciences, Northwestern Switzerland, Windisch, Switzerland

  • Venue:
  • PPPJ '06 Proceedings of the 4th international symposium on Principles and practice of programming in Java
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

Programming languages which support lazy evaluation allow the definition of infinite streams as for example the stream of natural numbers or of prime numbers. Such streams are infinite in the sense that arbitrary many elements can be accessed as these elements are computed "on demand".This paper describes how infinite streams can be implemented in Java, a language which does not support lazy evaluation directly. Two possible implementations are described and compared. Furthermore it is shown how streams can be defined as fixed points of maps on infinite streams and how formal power series can be defined using infinite streams. As user interface to work with such streams Groovy is used.