开发者

F# linq - How to filter for only unique values?

开发者 https://www.devze.com 2023-02-12 22:45 出处:网络
my seq linq is <@ db.Dictionaries |> Seq.filter(fun x -> x.ID_Line = l1 || x.ID_Line = l2) @>

my seq linq is

<@ db.Dictionaries
|> Seq.filter(fun x -> x.ID_Line = l1 || x.ID_Line = l2) @>
|> fun pquery ->
    <@ seq { for cd in db.DeltaCompares do
                for cl1 in %pquery do
                    for cl2 in %pquery do
                        yield
                            if cd.IID1 = cl1.IID && cd.IID2 = cl2.IID then
           开发者_高级运维                     Some(cl1, cl2)
                            else None } @>
    |> query |> Seq.choose id 
    |> Seq.collect(fun a -> [fst a; snd a])
    |> List.ofSeq

but here I need only unique values here...


Seq.distinct, or Seq.distinctBy will do what you want.

Presumably the query function can handle them, if you use it inside the quotation - but don't quote me on that.

0

精彩评论

暂无评论...
验证码 换一张
取 消