Lazy Data Streams

A Lazy Data Stream is a mix between an iterator and a list. A stream can be expanded by lazy calculation of an extra member.

Streams is a key component of the declarative programming engine in ShapeLogic starting from ShapeLogic 1.0.

Using streams to solve mathematical problems

Project Euler is a list of 178 mathematical problems that can be solved by computers. The first 10 mathematical problems have been solved in ShapeLogic using streams.

History

Lazy Data Streams are used in different functional languages e.g.

  • Haskell
  • Scala
  • Scheme

The advantages of a lazy data stream are

  • That you can use functional techniques on possible infinite streams of data
  • You still have access to previous elements in a calculation by an iterator
  • You only calculate the necessary elements

Examples of lazy infinite data streams

  • Lazy Data Streams to calculate all Fibonacci numbers
  • All even Fibonacci numbers
  • All even Fibonacci numbers greater than 1000