0
我最近閱讀了有關蹦牀作爲消除尾巴呼叫的方法。我想將我的某個功能轉換爲利用蹦牀的功能,但是我正在經歷艱難的時間(我從OO世界來到這裏)。瞭解如何將遞歸轉換爲蹦牀
def buildTree (X:DenseMatrix[Double], Y:DenseVector[Double], minBucket:Int):Node = {
// Get the split variable, split point and data for this data
val (splitVar, splitPoint, leftX, leftY, rightX, rightY) = chooseSplit(X, Y, minBucket);
// If we couldn't find a split, then we have a leaf
if(splitVar == Double.NegativeInfinity){
new Node(Y)
}else{
// Otherwise recursively build the children and create yourself as a vertex
val left = buildTree(leftX, leftY, minBucket))
val right = buildTree(rightX, rightY, minBucket))
new Node(Y, splitVar, splitPoint, left, right)
}
}
具體來說,如果我有兩個不同的遞歸調用我想在「更多()」語句來使,是好嗎?