eyeling 1.7.4 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eyeling.js +13 -6
- package/package.json +1 -1
package/eyeling.js
CHANGED
|
@@ -4722,19 +4722,26 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
4722
4722
|
const inputList = inputTerm.elems;
|
|
4723
4723
|
if (!(predTerm instanceof Iri)) return [];
|
|
4724
4724
|
const pred = internIri(predTerm.value);
|
|
4725
|
-
|
|
4725
|
+
|
|
4726
|
+
// Allow mapping *any* predicate (not just builtins).
|
|
4727
|
+
// Semantics: for each input element `el`, collect *all* solutions of `el pred ?y`
|
|
4728
|
+
// (facts, rules, and builtins), in order, and concatenate them into the output list.
|
|
4729
|
+
// If an element has no solutions, it contributes nothing.
|
|
4726
4730
|
if (!inputList.every((e) => isGroundTerm(e))) return [];
|
|
4727
4731
|
|
|
4728
4732
|
const results = [];
|
|
4729
4733
|
for (const el of inputList) {
|
|
4730
4734
|
const yvar = new Var('_mapY');
|
|
4731
4735
|
const goal2 = new Triple(el, pred, yvar);
|
|
4732
|
-
const sols =
|
|
4733
|
-
|
|
4734
|
-
const
|
|
4735
|
-
|
|
4736
|
-
|
|
4736
|
+
const sols = proveGoals([goal2], subst, facts, backRules, depth + 1, [], varGen);
|
|
4737
|
+
|
|
4738
|
+
for (const sol of sols) {
|
|
4739
|
+
const yval = applySubstTerm(yvar, sol);
|
|
4740
|
+
if (yval instanceof Var) continue;
|
|
4741
|
+
results.push(yval);
|
|
4742
|
+
}
|
|
4737
4743
|
}
|
|
4744
|
+
|
|
4738
4745
|
const outList = new ListTerm(results);
|
|
4739
4746
|
const s2 = unifyTerm(g.o, outList, subst);
|
|
4740
4747
|
return s2 !== null ? [s2] : [];
|