]> Repositorios git - scryer-prolog.git/commitdiff
stop applying (=..)/2 to variables in tabling/trie.pl
authorMark Thom <[email protected]>
Wed, 19 Feb 2020 21:43:06 +0000 (14:43 -0700)
committerMark Thom <[email protected]>
Wed, 19 Feb 2020 21:43:06 +0000 (14:43 -0700)
src/prolog/lib/tabling/trie.pl

index af3703edc1ff5aebaeb8b3ccfa617e8e009816e8..eb102df12e2c6eb8ee97d4b0e918476f7771fb2c 100644 (file)
 % For a term of the form p(a,q(b)), "returns" functor_data(p,2) and [a,q(b)].
 % p_trie_arity_univ(+Term,-FunctorData,-ArgumentsList).
 p_trie_arity_univ(Term,functor_data(Name,Arity),Arguments) :-
-  Term =.. [Name|Arguments],
-  functor(Term,_,Arity).
+  (  var(Term) ->
+     Name = var,
+     Arity = 0,
+     Arguments = []
+  ;  Term =.. [Name|Arguments],
+     functor(Term,_,Arity)
+  ).
 
 % Returns a new empty trie.
 trie_new(Trie) :-
@@ -110,7 +115,7 @@ trie_insert_succeed(Trie,Key,Value) :-
 % We don't use an extra argument to indicate earlier presence, as this increases the trail size.
 trie_insert(Trie,Key,Value) :-
   p_trie_arity_univ(Key,FunctorData,KeyList),
-  trie_insert_1(KeyList,FunctorData,Trie,Value). 
+  trie_insert_1(KeyList,FunctorData,Trie,Value).
 
 trie_insert_1([],FunctorData,Trie,Value) :-
   trie_get_children(Trie,Assoc),
@@ -182,7 +187,7 @@ trie_insert_1_1_1(>,_V,_L,R,Assoc,FunctorData,Trie,First,Rest,Value) :-
   % Look in the right part of the assoc tree.
   trie_insert_1_1(R,Assoc,FunctorData,Trie,First,Rest,Value).
 
-trie_insert_2(RegularTerm,Rest,Trie,Value) :-
+trie_insert_2(RegularTerm,Rest,Trie,Value) :-  
   p_trie_arity_univ(RegularTerm,FunctorData,KList),
   append(KList,Rest,KList2),
   trie_insert_1(KList2,FunctorData,Trie,Value).