eyeling 1.5.22 → 1.5.24

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.
Files changed (62) hide show
  1. package/README.md +1 -2
  2. package/examples/age.n3 +2 -3
  3. package/examples/backward.n3 +2 -3
  4. package/examples/basic-monadic.n3 +2 -3
  5. package/examples/cat-koko.n3 +5 -6
  6. package/examples/collect-all-in.n3 +6 -6
  7. package/examples/complex.n3 +2 -3
  8. package/examples/control-system.n3 +2 -2
  9. package/examples/crypto-builtins-tests.n3 +2 -2
  10. package/examples/deep-taxonomy-10.n3 +5 -0
  11. package/examples/deep-taxonomy-100.n3 +5 -0
  12. package/examples/deep-taxonomy-1000.n3 +5 -0
  13. package/examples/deep-taxonomy-10000.n3 +5 -0
  14. package/examples/derived-backward-rule-2.n3 +2 -3
  15. package/examples/derived-backward-rule.n3 +2 -2
  16. package/examples/derived-rule.n3 +2 -2
  17. package/examples/dijkstra.n3 +2 -3
  18. package/examples/dog.n3 +2 -3
  19. package/examples/drone-corridor-planner-v2.n3 +237 -0
  20. package/examples/drone-corridor-planner.n3 +131 -0
  21. package/examples/equals.n3 +3 -4
  22. package/examples/existential-rule.n3 +2 -2
  23. package/examples/expression-eval.n3 +2 -6
  24. package/examples/family-cousins.n3 +2 -4
  25. package/examples/fibonacci.n3 +2 -3
  26. package/examples/for-all-in.n3 +2 -2
  27. package/examples/french-cities.n3 +2 -3
  28. package/examples/fuse.n3 +2 -2
  29. package/examples/good-cobbler.n3 +2 -3
  30. package/examples/gps.n3 +2 -4
  31. package/examples/gray-code-counter.n3 +2 -5
  32. package/examples/hanoi.n3 +2 -3
  33. package/examples/liar.n3 +5 -0
  34. package/examples/light-eaters.n3 +2 -4
  35. package/examples/list-builtins-tests.n3 +27 -15
  36. package/examples/lldm.n3 +3 -4
  37. package/examples/math-builtins-tests.n3 +32 -134
  38. package/examples/monkey.n3 +2 -3
  39. package/examples/odrl-trust.n3 +2 -6
  40. package/examples/output/drone-corridor-planner-v2.n3 +819 -0
  41. package/examples/output/drone-corridor-planner.n3 +153 -0
  42. package/examples/output/list-builtins-tests.n3 +32 -0
  43. package/examples/output/pillar.n3 +36 -0
  44. package/examples/peano.n3 +2 -3
  45. package/examples/pi.n3 +2 -3
  46. package/examples/pillar.n3 +23 -0
  47. package/examples/polygon.n3 +2 -3
  48. package/examples/reordering.n3 +2 -3
  49. package/examples/rule-matching.n3 +2 -3
  50. package/examples/self-referential.n3 +3 -4
  51. package/examples/similar.n3 +3 -4
  52. package/examples/skolem.n3 +2 -2
  53. package/examples/snaf.n3 +2 -2
  54. package/examples/socrates.n3 +2 -2
  55. package/examples/spectral-week.n3 +2 -7
  56. package/examples/string-builtins-tests.n3 +19 -51
  57. package/examples/turing.n3 +2 -3
  58. package/examples/uri.n3 +2 -2
  59. package/examples/witch.n3 +2 -2
  60. package/examples/zebra.n3 +2 -2
  61. package/eyeling.js +30 -0
  62. package/package.json +1 -1
package/eyeling.js CHANGED
@@ -2558,6 +2558,36 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
2558
2558
  return s2 !== null ? [s2] : [];
2559
2559
  }
2560
2560
 
2561
+ // list:rest
2562
+ // true iff $s is a (non-empty) list and $o is the rest (tail) of that list.
2563
+ // Schema: $s+ list:rest $o-
2564
+ if (g.p instanceof Iri && g.p.value === LIST_NS + "rest") {
2565
+ // Closed list: (a b c) -> (b c)
2566
+ if (g.s instanceof ListTerm) {
2567
+ if (!g.s.elems.length) return [];
2568
+ const rest = new ListTerm(g.s.elems.slice(1));
2569
+ const s2 = unifyTerm(g.o, rest, subst);
2570
+ return s2 !== null ? [s2] : [];
2571
+ }
2572
+
2573
+ // Open list: (a b ... ?T) -> (b ... ?T)
2574
+ if (g.s instanceof OpenListTerm) {
2575
+ if (!g.s.prefix.length) return []; // can't compute rest without a known head
2576
+
2577
+ if (g.s.prefix.length === 1) {
2578
+ // (a ... ?T) rest is exactly ?T
2579
+ const s2 = unifyTerm(g.o, new Var(g.s.tailVar), subst);
2580
+ return s2 !== null ? [s2] : [];
2581
+ }
2582
+
2583
+ const rest = new OpenListTerm(g.s.prefix.slice(1), g.s.tailVar);
2584
+ const s2 = unifyTerm(g.o, rest, subst);
2585
+ return s2 !== null ? [s2] : [];
2586
+ }
2587
+
2588
+ return [];
2589
+ }
2590
+
2561
2591
  // list:iterate
2562
2592
  // true iff $s is a list and $o is a list (index value),
2563
2593
  // where index is a valid 0-based index into $s and value is the element at that index.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.5.22",
3
+ "version": "1.5.24",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [