Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/foldallmatch.metta
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
!(import! &self /home/carlo/code/prolog/PeTTa/lib/lib_import.metta)
!(use-module! aggregate)
!(import_prolog_function foldall)

(kb 1)
(kb 2)

Expand Down
2 changes: 1 addition & 1 deletion examples/functiontypes.metta
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(: wu1 (-> Number Expression Expression))
(: wu1 (-> Number Atom Atom))
(= (wu1 $a $b)
(42 $a $b))

Expand Down
2 changes: 1 addition & 1 deletion examples/lambda.metta
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;fake lambda (works in H-E MeTTa too):
(: apply (-> Expression %Undefined% %Undefined%))
(: apply (-> Atom %Undefined% %Undefined%))
(= (apply (lambda $var $body) $arg)
(eval (let $var $arg $body)))

Expand Down
2 changes: 1 addition & 1 deletion examples/myinterpreter.metta
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(: myinterpreter (-> Expression %Undefined%))
(: myinterpreter (-> Atom %Undefined%))
(= (myinterpreter $code)
(let $temp (println! ("Runtime-interpreting code" $code))
(eval $code)))
Expand Down
4 changes: 2 additions & 2 deletions examples/nars_direct.metta
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
!(import! &self (library lib_nars))

;PLN IMPLICATION TO CLAUSE COMPILATION EXTENSION:
(: => (-> Expression Expression Atom Atom))
(: => (-> Atom Atom Atom Atom))
(= (=> (cons , $args) $C $stvImp)
(progn (cut) (add-atom &self (= $C (Truth_Deduction (foldl-atom $args (stv 1.0 1.0) Truth_Deduction) $stvImp)))))
(= (=> $A $C $stvImp)
(add-atom &self (= $C (Truth_Deduction $A $stvImp))))

(: ? (-> Expression Atom))
(: ? (-> Atom Atom))
(= (? $term)
(unique-atom (collapse ($term (progn (reduce $term) ;ensures binding to specific answer, then combines evidence for all derived variants:
(foldl-atom (collapse (reduce $term)) (stv 0.5 0.0) Truth_Revision))))))
Expand Down
4 changes: 2 additions & 2 deletions examples/pln_direct.metta
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
!(import! &self (library lib_pln))

;PLN IMPLICATION TO CLAUSE COMPILATION EXTENSION:
(: => (-> Expression Expression Atom Atom))
(: => (-> Atom Atom Atom Atom))
(= (=> (cons , $args) $C $stvImp)
(progn (cut) (add-atom &self (= $C (Truth_ModusPonens (foldl-atom $args (stv 1.0 1.0) Truth_ModusPonens) $stvImp)))))
(= (=> $A $C $stvImp)
(add-atom &self (= $C (Truth_ModusPonens $A $stvImp))))

(: ? (-> Expression Atom))
(: ? (-> Atom Atom))
(= (? $term)
(unique-atom (collapse ($term (progn (reduce $term) ;ensures binding to specific answer, then combines evidence for all derived variants:
(foldl-atom (collapse (reduce $term)) (stv 0.5 0.0) Truth_Revision))))))
Expand Down
2 changes: 1 addition & 1 deletion examples/translatorrule_for.metta
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(: for (-> Expression Expression Expression Expression))
(: for (-> Atom Atom Atom Atom))
(= (for $var $collection $body)
(quote (let $var (superpose $collection)
$body)))
Expand Down
10 changes: 5 additions & 5 deletions lib/lib_he.metta
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(= (assertAlphaEqual $A $B)
(assert (=alpha $A $B)))

(: unify (-> Expression Expression Expression Expression %Undefined%))
(: unify (-> Atom Atom Atom Atom %Undefined%))

(= (unify $space $pattern $then $else)
(if (is-space $space)
Expand All @@ -29,7 +29,7 @@
(eval $then)
(eval $else)))

(: add-reduct (-> %Undefined% Expression Bool))
(: add-reduct (-> %Undefined% Atom Bool))
(= (add-reduct $space $f)
(let* (($headbody (cdr-atom $f))
($head (car-atom $headbody))
Expand All @@ -51,17 +51,17 @@
(= (for-each-in-atom $L $f)
(map-atom $L $f))

(: evalc (-> Expression %Undefined% %Undefined%))
(: evalc (-> Atom %Undefined% %Undefined%))
(= (evalc $expression &self)
(eval $expression))

;Quoting
(: unquote (-> Expression %Undefined%))
(: unquote (-> Atom %Undefined%))
(= (unquote (quote $A))
(let $cut (cut) (eval $A)))
(= (unquote $A) (quote (unquote $A)))

(: noreduce-eq (-> Expression Expression Bool))
(: noreduce-eq (-> Atom Atom Bool))
(= (noreduce-eq $A $B)
(== $A $B))

Expand Down
4 changes: 2 additions & 2 deletions src/translator.pl
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@
%Selectively apply translate_args for non-Expression args while Expression args stay as data input:
translate_args_by_type([], _, [], []) :- !.
translate_args_by_type([A|As], [T|Ts], GsOut, [AV|AVs]) :-
( T == 'Expression' -> AV = A, GsA = []
( T == 'Atom' -> AV = A, GsA = []
; translate_expr(A, GsA1, AV),
( (T == '%Undefined%' ; T == 'Atom')
( T == '%Undefined%'
-> GsA = GsA1
; append(GsA1, [('get-type'(AV, T) *-> true ; 'get-metatype'(AV, T))], GsA))),
translate_args_by_type(As, Ts, GsRest, AVs),
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pidfile="/tmp/metta_pid_map.$$"

for f in ./examples/*.metta; do
base=$(basename "$f")
case "$base" in repl.metta|llm_cities.metta|torch.metta|greedy_chess.metta|git_import2.metta)
case "$base" in repl.metta|llm_cities.metta|torch.metta|greedy_chess.metta|git_import2.metta|foldallmatch.metta|foldall.metta|foldallspacecount.metta)
continue ;;
esac
run_test "$f" &
Expand Down