Yep, it's not very obvious but you need IEnumerable.untyped_to_list. Usage shown below:

1
2
3
4
5
6
7
8
9
10
11
12
13
> open System.Text.RegularExpressions;;

> let re = new Regex("r");;

val re : Regex

> let matches = re.Matches("robert susan ruth");;

val matches : MatchCollection

> let (matches_list : Match list) = IEnumerable.untyped_to_list matches;;

val matches_list : Match list
By on 6/16/2006 7:25 AM ()

Oh yeah, should probably mention there is no such thing as a safe upcast, with out generics the programmer is free to get this wrong [:)]. From the F# docs for untyped_to_list:

1
2
3
4
5
6
7
8
9
10
11
///Transform a loosely-typed System.Collections IEnumerable to a strongly typed F# list.

///The use of thus function usually requires a type annotation.

///

///The use of this function usually requires a type annotation.

///An incorrect type annotation may result in runtime type

///errors.
By on 6/16/2006 7:32 AM ()

How is this done now? I can't find untyped_to_list anywhere.

By on 8/20/2009 2:22 AM ()

How is this done now? I can't find untyped_to_list anywhere.

Renamed/Moved to Seq.cast.

By on 8/20/2009 9:23 AM ()

Ah, I missed that.

Thanks.

By on 8/20/2009 1:57 PM ()

Never mind, I found another thread where you explain that it's best to just use for-do.

Since I want to do a fold, I just made a for-do yield in a sequence generator.

By on 8/20/2009 2:26 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