I've recently read about trampolining as a way to eliminate tail calls. I'd like to convert one of my functions to something that utilizes trampolines, but I'm having a tough time getting going (I'm coming here from the OO world).
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)
}
}
Specifically, if I have two different recursive calls I want to make in a 'More()' statement, is that okay?