private void FoldHelper <T>(List <T> list, FoldBlock <T> expand, ParameterisedBlock result, LoadableValue curr_result, int it) { if (it < list.Count) { expand(it, list[it], curr_result, (next_result) => FoldHelper(list, expand, result, next_result, it + 1)); } else { result(curr_result); } }
/** * Generate code for a list using a fold (i.e., each computation in the list * is made from the previous computation). */ public void Fold <T>(LoadableValue initial, List <T> list, FoldBlock <T> expand, ParameterisedBlock result) { FoldHelper(list, expand, result, initial, 0); }