F# slicing array by indices array
How can I overload . for F# array to slice an array based on an arbitrary index array?
let x = [|1..10|]; let indx = [|4;1|];
[| for i in indx ->x.[i]|]
would work, it would be nicer to be able using x.[indx] directly.
You can always write an F# extension method to get close on the syntax
let a = [| 1..10 |] let idx = [|4;1|] type 'T ```` with //' member this.Slice(indices:int array) = [| for i in indices -> this.[i] |] printfn "%A" (a.Slice idx)
but since arrays already have an indexer it doesn't appear there's a way to overload/change it.