3
下面的代碼段是否有快捷方式?Scala中的固定點
while (true) {
val newClusters = this.iterate(instances, clusters)
if (newClusters == clusters) {
return clusters
}
clusters = newClusters
}
我想計算固定點,即執行一個函數,使其結果穩定。你是否知道任何適合我的目的的高階函數?
對不起,但我沒有看到我的方法有任何區別,除了你使用遞歸的事實。不幸的是,它不會讓我的代碼更短或更易讀。 – user3267915
不用擔心,通過「頭等功能」誤解了「更高級功能」:)也許庫/包函數可能是傳達查詢的另一個命名:) – elm