views:

829

answers:

2

Is there an equivalent operator to Haskell's list difference operator \\ in F#?

+3  A: 

Nope... Just write it and make it an infix operator --using the set of special characters. // will work as an infix operator, for example, but not \\. See the manual:

infix-op :=

or || & && <OP >OP $OP = |OP &OP ^OP :: -OP +OP *OP /OP %OP

**OP

prefix-op :=

!OP ?OP ~OP -OP +OP % %% & &&
nlucaroni
+1  A: 

Just convert the lists to sets using the built-in set function and then use the built-in - operator:

set xs - set ys

For example:

> set [1..5] - set [2..4];;
val it : Set<int> = seq [1; 5]
Jon Harrop
This won't handle duplicates correctly.
Ganesh Sittampalam