0
votes

I have a prolog program that accepts a user input and the uses that input to search a database for possible matches.

    findall(Disease,symptom(Disease,Symptom),Possibles)

This code correctly adds all possible diseases from one user input, but does not add to the same list on the next loop. For example, the user enters "fever", the program creates a list of all possible diseases. But when the user enters the next input on the next loop "headache" the only thing on the list still is the diseases from the first input. Is it possible in Prolog to add an element to the same list every loop?

1
instead of telling us about your code and errors, please show us your code and query and output and errors -- exactly as is. see minimal reproducible example. - Will Ness

1 Answers

1
votes

SWI-Prolog has findall/4, that appends to an existing list, its fourth argument. To avoid duplicates, the goal (the second argument) could inspect what is existing...