Check if an element is within a sequence

前端 未结 5 703
野性不改
野性不改 2021-01-07 23:51

how to check if an element is contained within a sequence? I expected some Seq.contains, but i could not find it. Thanks

EDIT: Or, for an easier tas

5条回答
  •  遥遥无期
    2021-01-08 00:31

    Seq.exists again, but with slightly different syntax -

    let testseq = seq [ 1; 2; 3; 4 ]
    let testn = 2
    testseq |> Seq.exists (fun x -> x = testn)
    

    See MSDN F#: Seq.exists function: https://msdn.microsoft.com/en-us/library/ee353562.aspx

    Lots of other good ones there too!

提交回复
热议问题