[Haskell-cafe] Generators? Iterators?
Erik de Castro Lopo
mle+hs at mega-nerd.com
Sat Apr 23 05:47:38 UTC 2016
Christopher Howard wrote:
> Hi. I'm more in the shallow end of the Haskell pool right now, so
> forgive me if this is really basic... In Haskell, what is the class for
> things that can provide an infinite sequence?
People generally do this with lists and Haskell's lazy evaluation. For
instance:
let x = [1 .. ]
produces the infinite list [1,2,3, .....].
Haskell's lazily evaluated lists allow for incredibly elegant solutions
for some sorts of problems, like the spigot algorithm for generating
(among other things) the digits of PI:
http://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/spigot.pdf
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the Haskell-Cafe
mailing list