The namespaces have been rearraged in fslib recently, the documentation in the distribution explains the new namespace structure well, but it appears not all documentation has been updated. I believe the new namespace is Microsoft.FSharp.Collections.List.

Reflector is your friend here: [link:www.aisto.com]

By on 1/3/2007 7:49 AM ()

My project is behaving very strange....I do not seem to get intellisence to find System.FSharp.Collections.List but I am able to define a type of System.FSharp.Collections.List<String> !! I also have in my F# project (dll) some functions that return lists but they do not appear in the intellisence in VS...

Anyone know how to loop through this mysterious List object in C# ??

By on 1/3/2007 9:24 AM ()

This sample is taken from my F# book, Foundations of F#, available from pre-order now ;)

If you have a function that returns a list.

1
2
let getList() =
    [1; 2; 3]

You can iterater though it with the following code:

1
2
3
4
5
6
7
8
9
static void GetList()
{
    Microsoft.FSharp.Collections.List<int> l = DemoModule.getList();
    while (l != null)
    {
        Console.WriteLine(l.Head);
        l = l.Tail;
    }
}

However, I use this as an example to say that it is difficult to iterate over F# lists in C# so return System.Collections.Generic.Lists instead. Just call List.to_ResizeArray before you return your list (ResizeArray is the F# name for a generic list). This way you also avoid the depency on FSLib.dll which will save you trouble, as new versions of this are released quite frequently.

By on 1/3/2007 9:33 PM ()
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