相关疑难解决方法(0)

如何在不使用引用的情况下删除F#序列中的重复项

我有一个排序的序列,想要通过它并返回序列中的唯一条目.我可以使用以下函数来完成它,但它使用引用变量,我不认为这是解决问题的正确方法.

    let takeFirstCell sectors = 
        let currentRNCId = ref -1
        let currentCellId = ref -1
        seq {
            for sector in sectors do
                if sector.RNCId <> !currentRNCId || sector.CellId <> !currentCellId then
                    currentRNCId := sector.RNCId
                    currentCellId := sector.CellId
                    yield sector
        }
Run Code Online (Sandbox Code Playgroud)

我怎么能以功能的方式做到这一点?

f#

3
推荐指数
3
解决办法
4542
查看次数

标签 统计

f# ×1