F#: Filter items found in one list from another list

后端 未结 3 621
野趣味
野趣味 2021-01-20 06:57

Say I have two lists:

let a = [1 .. 1000]
let b = [250 .. 500]

How do I get a new list that contains the values {1-249, 501-1000}?

3条回答
  •  深忆病人
    2021-01-20 07:04

    If you're working against the 3.5 framework or higher you could do the following

    let c = System.Linq.Enumerable.Except(a,b)
    

    It's not a pure F# solution but it gets the job done. The return will be an instance of IEnumerable though and not an F# list.

提交回复
热议问题