Is there LazyList type in F#? Is it similar to sequences or is there some difference? Can you please provide me a small example of a lazylist?

There is a LazyList type in the PowerPack. See these links for some examples and differences with seq (IEnumerable):

[link:stackoverflow.com]

[link:cs.hubfs.net]

[link:stackoverflow.com]

[link:stackoverflow.com]

quoting myself:

The F# LazyList (in the FSharp.PowerPack.dll) has three useful properties:

  • it is lazy (evaluation of the nth element will not happen until it is first demanded)
  • it does not recompute (re-evaluation of the nth element on the same object instance will not recompute it - it caches each element after it's first computed)
  • you can 'forget' prefixes (as you 'tail' into the list, the no-longer-referenced prefix is available for garbage collection)

The first property is common with seq (IEnumerable), but the other two are unique to LazyList and very useful for <certain problems>

By on 3/17/2011 2:08 PM ()

Hi,

look for Seq.nth and Seq.cache

By on 3/15/2011 7:50 AM ()

Hi,

Thank you very much. I checked and am now able to access an element of a sequence by providing the index.

By on 3/15/2011 8:08 AM ()

Hi,

I was looking for all possible alternatives.

Sequences work.

But, what about LazyList?

How is it different from a sequence?

I wanted to try a small example with LazyList.

But I was not able to use LazyLists.

From the below reference, I see that LazyLists are in "microsoft.fsharp.collections" module. But is it currently present in this module?

Microsoft.FSharp.Collections.LazyList

By on 3/17/2011 12:48 AM ()

To be honest I don't know.

I think they might have moved the LazyList into the F#-Powerpack.

But you can find a implementation of this structure here: [link:fssnip.net] - I guess that's even more helpfull to you since you can check all the details.

By on 3/17/2011 3:52 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper