Thanks, this is a great suggestion. It turns out that because slicing syntax is a syntactic translation, you can add slicing syntax via an extension member:

1
2
3
4
5
6
7
8
9
10
11
12
13
 

type System.Collections.Generic.List<'T> with 
    member x.GetSlice(a,b) = 
        let a = defaultArg a 0
        let b = defaultArg b (x.Count-1)
        [| for i in a .. b -> x.[i] |]


let ra = new System.Collections.Generic.List<int>( [1 .. 100] )

ra.[3..4]

Kind regards

don

By on 5/19/2009 1:50 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