the String.Split gives you a string array.

The RemoveAt-Method is defined for collections - for example lists.

You can simulate the RemoveAt with Array.append and Array.blt though.

By on 6/16/2009 7:10 AM ()

the String.Split gives you a string array. The RemoveAt-Method is defined for collections - for example lists. You can simulate the RemoveAt with Array.append and Array.blt though.

just tried googling for it but that ancient code out there confuses me even more, how is one suppose to append and blit I tried

1
2
3
4
5
6
7
8
let order = 4
let numberar = [|0 .. order * order - 1|];
let nrs = 
   let numbs = [||]
   let g = Array.blit numberar 5 numbs 0 
   numbs

printfn " nrs %A" nrs      // ==> [||]

the "let g =" I merely added to dispense with the need to be an unit.
I read somewhere that numbs here need to have enough space, but whatever is put there is copied into nrs.
and blit defies functional logic in my opinion anyway.
slicing works.

still I reckon somewhere all this can be used in a functional F# statement which gives me 4 numbers out of

numberarr or its list equaivalent that sums toward 126 (the "magic sum"), the way I have is still too much

imperative in nature.

By on 6/18/2009 4:35 AM ()

Thanks for your quick answer. As far as I understood since I am using not the split method of F# but of the .NET type String the returned array is of type [link:msdn.microsoft.com] which implements the RemoveAt method.

By on 6/16/2009 7:18 AM ()

The method you're using is an explicit interface implementation, which means that you have to cast to the interface before calling it (in F# or any other .NET language that I know of). Also note that the description in the documentation that you've cited indicates that the method will always throw an exception, since arrays are of a fixed size. What are you hoping to achieve?

If you want to call the method anyway, the syntax including the cast looks like this:

1
2
3
let a = "This is is a test";; 
(a.Split(' ') :> System.Collections.IList).RemoveAt(1)
By on 6/16/2009 8:32 AM ()

Not sure what you're trying to do - but slicing is your friend:

1
2
3
> "This is a test".Split(' ').[1..];;

val it : string [] = [|"is"; "a"; "test"|]
By on 6/16/2009 10:34 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