This works (kind of):

1
2
3
let inline get (arr:^a) (ind:^b) = 
  (^a : (member get_Item : ^b -> ^c)(arr,ind)) 

Unfortunately, this will only work with types that truly expose a "get_Item" method, but not with types that F# augments with implicit "get_Item" methods (such as arrays). So this will work:

1
2
let hello = get (Map.ofList [1,"hello"]) 1

But this will fail at runtime:

1
2
let test = get [|1;2;3|] 1
By on 11/21/2009 9:10 AM ()

This "just worked" for arrays with the previous CTP.

By on 11/21/2009 9:16 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