Skip to content

Commit

Permalink
Merge branch 'trueagi-io:master' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
royward authored Dec 24, 2024
2 parents c5aed03 + 8feced6 commit 0a2eb9a
Show file tree
Hide file tree
Showing 39 changed files with 6,716 additions and 6,742 deletions.
2,481 changes: 1,635 additions & 846 deletions .Attic/metta_lang/metta_compiler.pl

Large diffs are not rendered by default.

47 changes: 40 additions & 7 deletions .Attic/metta_lang/metta_compiler_lib.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
:- discontiguous get_type_sig/3.


from_prolog_args(_,X,X).
:-dynamic(pred_uses_fallback/2).
:-dynamic(pred_uses_impl/2).

pred_uses_impl(F,A):- transpile_impl_prefix(F,Fn),current_predicate(Fn/A).

mc_fallback_unimpl(Fn,Arity,Args,Res):-
(pred_uses_fallback(Fn,Arity);(length(Args,Len),\+pred_uses_impl(Fn,Len))),!,
get_operator_typedef_props(_,Fn,Arity,Types,_RetType0),
current_self(Self),
maybe_eval(Self,Types,Args,NewArgs),
[Fn|NewArgs]=Res.

maybe_eval(_Self,_Types,[],[]):-!.
maybe_eval(Self,[T|Types],[A|Args],[N|NewArgs]):-
into_typed_arg(30,Self,T,A,N),
maybe_eval(Self,Types,Args,NewArgs).


'mc__:'(Obj, Type, [':',Obj, Type]):- current_self(Self), sync_type(10, Self, Obj, Type). %freeze(Obj, get_type(Obj,Type)),!.
sync_type(D, Self, Obj, Type):- nonvar(Obj), nonvar(Type), !, arg_conform(D, Self, Obj, Type).
sync_type(D, Self, Obj, Type):- nonvar(Obj), var(Type), !, get_type(D, Self, Obj, Type).
sync_type(D, Self, Obj, Type):- nonvar(Type), var(Obj), !, set_type(D, Self, Obj, Type). %, freeze(Obj, arg_conform(D, Self, Obj, Type)).
sync_type(D, Self, Obj, Type):- freeze(Type,sync_type(D, Self, Obj, Type)), freeze(Obj, sync_type(D, Self, Obj, Type)),!.


%'mc__get-type'(Obj,Type):- attvar(Obj),current_self(Self),!,trace,get_attrs(Obj,Atts),get_type(10, Self, Obj,Type).
'mc__get-type'(Obj,Type):- current_self(Self), !, get_type(10, Self, Obj,Type).

%%%%%%%%%%%%%%%%%%%%% arithmetic

% get_type_sig('+',['Number','Number'],'Number').
Expand All @@ -22,8 +52,9 @@

%%%%%%%%%%%%%%%%%%%%% comparison

'mc__=='(A,A,1) :- !.
'mc__=='(_,_,0).
'mc__=='(A,B,TF) :- (var(A);var(B)),!,A=B, TF='True'.
'mc__=='(A,B,TF) :- as_tf(A=B,TF).
%'mc__=='(_,_,0).

'mc__<'(A,B,R) :- number(A),number(B),!,(A<B -> R=1 ; R=0).
'mc__<'(A,B,['<',A,B]).
Expand All @@ -36,15 +67,17 @@

'mc__cons-atom'(A,B,[A|B]).

%%%%%%%%%%%%%%%%%%%%%superpose,collapse

'mi__superpose'([H|_],H).
'mi__superpose'([_|T],R):-'mi__superpose'(T,R).

%%%%%%%%%%%%%%%%%%%%% misc

'mc__empty'(_) :- fail.

'mc__stringToChars'(S,C) :- string_chars(S,C).

'mc__charsToString'(C,S) :- string_chars(S,C).

mc__assertEqualToResult(A, B, C) :- u_assign([assertEqualToResult, A, B], C).



mc__empty(_):-!,fail.

Loading

0 comments on commit 0a2eb9a

Please sign in to comment.