diff --git a/ml.cpp b/ml.cpp index 490d782..b2efb51 100644 --- a/ml.cpp +++ b/ml.cpp @@ -111,12 +111,12 @@ MlValue::MlValue(const std::vector ¶ms, MlValue ret, MlEnvironment list.push_back(ret); // // Lambdas capture only variables that they know they will use. -// std::vector used_atoms = ret.get_used_atoms(); -// for (size_t i = 0; i < used_atoms.size(); i++) { -// // If the environment has a symbol that this lambda uses, capture it. -// if (env.has(used_atoms[i])) -// lambda_scope.set(used_atoms[i], env.get(used_atoms[i])); -// } + std::vector used_atoms = ret.get_used_atoms(); + for (size_t i = 0; i < used_atoms.size(); i++) { + // If the environment has a symbol that this lambda uses, capture it. + if (env.has(used_atoms[i])) + lambda_scope.set(used_atoms[i], env.get(used_atoms[i])); + } } // Construct a builtin function