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