Featured post
haskell - Are infinite lists useful for any real world applications? -
i've been using haskell quite while now, , i've read of real world haskell , learn haskell. want know whether there point language using lazy evaluation, in particular "advantage" of having infinite lists, there task infinite lists make easy, or task possible infinite lists?
here's utterly trivial day-to-day useful example of infinite lists come in handy: when have list of items want use initialize key-value-style data structure, starting consecutive keys. so, have list of strings , want put them intmap
counting 0. without lazy infinite lists, you'd walk down input list, keeping running "next index" counter , building intmap
go.
with infinite lazy lists, list takes role of running counter; use zip [0..]
list of items assign indices, intmap.fromlist
construct final result.
sure, it's same thing in both cases. having lazy infinite lists lets express concept more directly without having worry details length of input list or keeping track of counter.
- Get link
- X
- Other Apps
Comments
Post a Comment