Or if you don't want to deal with Sets you can do it like this:

let filterAr totalArray filterArray =

Array.filter(fun (a : 'a when 'a :> System.IComparable) ->

not (Array.exists(fun b -> 0 = a.CompareTo(b)) filterArray) ) totalArray

filterAr [|"A";"B";"C"|] [|"B"|]

By on 11/4/2010 9:29 AM ()

Try:

1
2
(set totalArray - set filterArray) |> Set.toArray
By on 10/29/2010 3:29 PM ()

Hi,
Thank you very much, your code works.
However, I have no idea about set, is it new in F#?
Thanks again!

By on 10/30/2010 1:05 AM ()

(set totalArray - set filterArray) |> Set.toArray

There is come cognitive dissonance for me here because "(set ..." looks like a verb.

If this is more clear to you (it is to me) then you can use:

(Set.ofArray totalArray - Set.ofArray filterArray) |> Set.toArray

Of course "set" does have the most definitions of any word in the English language...

By on 10/30/2010 8:22 AM ()

... on par with the word object.

By on 11/4/2010 10:44 AM ()

"set" is a function that makes a Set<'T> out of a sequence.

[link:msdn.microsoft.com]

[link:msdn.microsoft.com]

By on 10/30/2010 2:10 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