From bf78787270a461a858132a3742e18eb10beabc79 Mon Sep 17 00:00:00 2001 From: Luke Peterson Date: Tue, 12 Mar 2024 11:02:35 +0900 Subject: [PATCH 1/5] Adding `merge-space` operation, to merge atoms from a src space into a dst --- lib/src/metta/runner/stdlib.metta | 4 ++++ lib/src/metta/runner/stdlib.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/lib/src/metta/runner/stdlib.metta b/lib/src/metta/runner/stdlib.metta index 04f1fcde0..8e2d8f1be 100644 --- a/lib/src/metta/runner/stdlib.metta +++ b/lib/src/metta/runner/stdlib.metta @@ -268,6 +268,10 @@ (let $pattern $atom (let* $tail $template)) $template ))) +(: merge-space (-> Atom %Undefined% Atom)) +(= (merge-space $dst $space) + (let $x $space (add-atom $dst $x))) + (: car-atom (-> Expression Atom)) (= (car-atom $atom) (eval (if-decons-expr $atom $head $_ diff --git a/lib/src/metta/runner/stdlib.rs b/lib/src/metta/runner/stdlib.rs index a3c2378cd..cedfca759 100644 --- a/lib/src/metta/runner/stdlib.rs +++ b/lib/src/metta/runner/stdlib.rs @@ -1466,6 +1466,7 @@ mod non_minimal_only_stdlib { (= (if False $then $else) $else) (: Error (-> Atom Atom ErrorType)) + (= (merge-space $dst $space) (let $x $space (add-atom $dst $x))) ; quote prevents atom from being reduced (: quote (-> Atom Atom)) From 8b0febc47ad2d7303f15069952b8b6df3a55307e Mon Sep 17 00:00:00 2001 From: luketpeterson <36806965+luketpeterson@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:11:27 +0900 Subject: [PATCH 2/5] Update lib/src/metta/runner/stdlib.rs Co-authored-by: Vitaly Bogdanov --- lib/src/metta/runner/stdlib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/metta/runner/stdlib.rs b/lib/src/metta/runner/stdlib.rs index cedfca759..6b33760e0 100644 --- a/lib/src/metta/runner/stdlib.rs +++ b/lib/src/metta/runner/stdlib.rs @@ -1466,7 +1466,7 @@ mod non_minimal_only_stdlib { (= (if False $then $else) $else) (: Error (-> Atom Atom ErrorType)) - (= (merge-space $dst $space) (let $x $space (add-atom $dst $x))) + (= (merge-space $dst $space) (add-atom $dst $space)) ; quote prevents atom from being reduced (: quote (-> Atom Atom)) From d783c4b3f0a7601920ddee900818629e0b09598b Mon Sep 17 00:00:00 2001 From: Luke Peterson Date: Wed, 13 Mar 2024 20:39:57 +0900 Subject: [PATCH 3/5] rename merge-space to add-reduct, and updating arguments --- lib/src/metta/runner/stdlib.metta | 5 ++--- lib/src/metta/runner/stdlib.rs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/metta/runner/stdlib.metta b/lib/src/metta/runner/stdlib.metta index 8e2d8f1be..ef82180ff 100644 --- a/lib/src/metta/runner/stdlib.metta +++ b/lib/src/metta/runner/stdlib.metta @@ -268,9 +268,8 @@ (let $pattern $atom (let* $tail $template)) $template ))) -(: merge-space (-> Atom %Undefined% Atom)) -(= (merge-space $dst $space) - (let $x $space (add-atom $dst $x))) +(: add-reduct (-> Grounded %Undefined% ())) +(= (add-reduct $dst $atom) (add-atom $dst $atom)) (: car-atom (-> Expression Atom)) (= (car-atom $atom) diff --git a/lib/src/metta/runner/stdlib.rs b/lib/src/metta/runner/stdlib.rs index 6b33760e0..c0c97c833 100644 --- a/lib/src/metta/runner/stdlib.rs +++ b/lib/src/metta/runner/stdlib.rs @@ -1466,7 +1466,8 @@ mod non_minimal_only_stdlib { (= (if False $then $else) $else) (: Error (-> Atom Atom ErrorType)) - (= (merge-space $dst $space) (add-atom $dst $space)) + (: add-reduct (-> Grounded %Undefined% ())) + (= (add-reduct $dst $atom) (add-atom $dst $atom)) ; quote prevents atom from being reduced (: quote (-> Atom Atom)) From f73120f60bb08f22d34cee6abac6559ffc8b658f Mon Sep 17 00:00:00 2001 From: luketpeterson <36806965+luketpeterson@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:36:36 +0900 Subject: [PATCH 4/5] Update lib/src/metta/runner/stdlib.rs Co-authored-by: Vitaly Bogdanov --- lib/src/metta/runner/stdlib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/metta/runner/stdlib.rs b/lib/src/metta/runner/stdlib.rs index c0c97c833..ee1ed7d8d 100644 --- a/lib/src/metta/runner/stdlib.rs +++ b/lib/src/metta/runner/stdlib.rs @@ -1466,7 +1466,7 @@ mod non_minimal_only_stdlib { (= (if False $then $else) $else) (: Error (-> Atom Atom ErrorType)) - (: add-reduct (-> Grounded %Undefined% ())) + (: add-reduct (-> Grounded %Undefined% (->))) (= (add-reduct $dst $atom) (add-atom $dst $atom)) ; quote prevents atom from being reduced From b2f1db17d30d73844431d245faad85eb7b8d6666 Mon Sep 17 00:00:00 2001 From: luketpeterson <36806965+luketpeterson@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:36:42 +0900 Subject: [PATCH 5/5] Update lib/src/metta/runner/stdlib.metta Co-authored-by: Vitaly Bogdanov --- lib/src/metta/runner/stdlib.metta | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/metta/runner/stdlib.metta b/lib/src/metta/runner/stdlib.metta index ef82180ff..bcdfb2f38 100644 --- a/lib/src/metta/runner/stdlib.metta +++ b/lib/src/metta/runner/stdlib.metta @@ -268,7 +268,7 @@ (let $pattern $atom (let* $tail $template)) $template ))) -(: add-reduct (-> Grounded %Undefined% ())) +(: add-reduct (-> Grounded %Undefined% (->))) (= (add-reduct $dst $atom) (add-atom $dst $atom)) (: car-atom (-> Expression Atom))