Skip to content

Commit

Permalink
GUESS ¯\_ :( _/¯ what version of unify they are trying to use? ¯(°_…
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Dec 11, 2024
1 parent d714434 commit 3c1cba3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions prolog/metta_lang/metta_eval.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1163,19 +1163,23 @@
% =================================================================
% =================================================================
% =================================================================
sub_part(Container,Item):- is_space(Container),!,metta_atom(Container,Item).
sub_part(Container,Item):- is_list(Container),!,member(Item,Container).
metta_container_sub_part(Container,Item):- is_space(Container),!,metta_atom(Container,Item).
metta_container_sub_part(Container,Item):- is_list(Container),!,member(Item,Container).

% GUESS `¯\\_ :( _/¯` what version of unify they are trying to use? ¯(°_o)/¯

% 1) If Arg1 is a space, then we redirect to a 'match' operation.
eval_20(Eq,RetType,Depth,Self,['unify',Arg1,Arg2|Args],Res):- is_space(Arg1), !,
eval_args(Eq,RetType,Depth,Self,['match',Arg1,Arg2|Args],Res).
% require someone declared this a container of some sort?
% 2) If Arg1 and Arg2 are nonvars and Arg1 is declared a 'Container', then use 'container-unify'
eval_20(Eq,RetType,Depth,Self,['unify',Arg1,Arg2|Args],Res):- nonvar(Arg1), nonvar(Arg2), get_type(Depth,Self,Arg1,'Container'),
eval_args(Eq,RetType,Depth,Self,['container-unify',Arg1,Arg2|Args],Res).
% 3) Otherwise, default to using 'if-unify' for the unify operation.
eval_20(Eq,RetType,Depth,Self,['unify',Arg1,Arg2|Args],Res):- !,
eval_args(Eq,RetType,Depth,Self,['if-unify',Arg1,Arg2|Args],Res).

eval_20(Eq,RetType,Depth,Self,['container-unify',Arg1,Arg2,Then|ElseL],Res):-
((sub_part(Arg1,Part),eval_args_true(Eq,'Bool',Depth,Self,['==',Part,Arg2]))
((metta_container_sub_part(Arg1,Part),eval_args_true(Eq,'Bool',Depth,Self,['==',Part,Arg2]))
*-> eval_args(Eq,RetType,Depth,Self,Then,Res)
; (ElseL=[Else],eval_args(Eq,RetType,Depth,Self,Else,Res))).

Expand Down

0 comments on commit 3c1cba3

Please sign in to comment.