Created
April 20, 2012 04:58
-
-
Save jokester/2426119 to your computer and use it in GitHub Desktop.
snippet for "why can't I subtitude functor with variable in a predicate" @ stackoverflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% facts : sname(ID,NAME) | |
sname(1,ada). | |
sname(2,bob). | |
% facts : point(ID,POINT) | |
point(1,80). | |
point(2,81). | |
% working search in example | |
search_by_name(Key,Value) :- | |
Key == name, | |
sname(ID,Value), | |
point(ID,Point), | |
write(Value),write(Point),nl. | |
% a more general search I want to write | |
% but not accepted by BProlog | |
% search_by_attr(Key,Value) :- | |
% Key(ID,Value), | |
% sname(ID,Name), | |
% point(ID,Point), | |
% write(Name),write(Point),nl. | |
% a working one | |
search_by_attr(Key,Value) :- | |
call(Key,ID,Value), | |
sname(ID,Name), | |
point(ID,Point), | |
write(Name),write(Point),nl. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment