Is there an equivalent operator to Haskell's list difference operator \\
in F#?
From stackoverflow
fryguybob
-
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 % %% & &&
From nlucaroni -
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]
Ganesh Sittampalam : This won't handle duplicates correctly.From Jon Harrop
0 comments:
Post a Comment