Unendliche Datenstrukturen

nats :: [ Integer ]
nats = from 0 where
    from x = x : from (x+1)

fibs :: [ Integer ]
fibs = 0 : 1 
     : zipWith (+) fibs ( drop 1 fibs )
das ist möglich, wenn der tail jeder Listenzelle erst bei Bedarf erzeugt wird.

(Bedarfsauswertung, lazy evaluation)

lazy Liste = Stream = Pipeline, vgl. InputStream (Console)



Johannes Waldmann 2011-07-07