sbool nlLogic_twoStageProcessing_verbose; // stage1/stage2: "" or mech list name svoid nlLogic_twoStageProcessing(S input, S stage1, S stage2, L resultsOut) { L results1 = nlLogic_processInputOrFact(input, false, stage1); // Collect results of stage 1 nlLogic_collectExecutedRulesWithOutputOrFacts(results1, resultsOut); // Collect inputs for stage 2 Set newInputs = nlLogic_inputsFromExecutedRules(litorderedset(input), results1); for (S s : newInputs) { if (nlLogic_twoStageProcessing_verbose) print("Stage 2: " + s); L results2 = nlLogic_processInputOrFact(s, false, stage2); // Collect results of stage 2 nlLogic_collectExecutedRulesWithOutputOrFacts(results2, resultsOut); } }