Is there an equivalent operator to Haskell's list difference operator \\
in F#?
views:
829answers:
2
+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
2008-09-12 19:41:25
+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
2009-05-06 02:29:13
This won't handle duplicates correctly.
Ganesh Sittampalam
2009-06-18 07:20:32