Reputation: 1
How do I combine weatherInfo(X,Y)
with airDensity(X,Y)
to make it into 1 list. I want it to be something like this if possible.
:- dynamic analize/3
outlook(Sunny).
outlook(Overcast).
outlook(Rain).
temperature(Hot).
temperature(Mild).
temperature(Cool).
humidity(Normal).
humidity(High).
windy(True).
windy(False).
weatherInfo(Sunny,Mild).
weatherInfo(Sunny,Cool).
weatherInfo(Overcast,Hot).
weatherInfo(Overcast,Mild).
weatherInfo(Overcast,Cool).
weatherInfo(Rain,Mild).
weatherInfo(Rain,Cool).
airDensity(Normal,False).
airDensity(Normal,True).
airDensity(High,False).
airDensity(High,True).
prediction(Result):-
analize([],[], _).
analize([H1|T1], [H2,T2], Result),
append(T1, [H2,T2], Result),
assertz([H1|T1], _, [H2,T2]),
Result =.. [[H1|T1], [H2,T2]),
write(L1, L2),
analize(NewT, NewL, Result).
I need to do delete old data but I don't know where I'm supposed to do it. Is it after append or before append?
Upvotes: 0
Views: 221
Reputation: 4998
A general comment: Sunny
is a variable, so outlook(Sunny).
asserts that any value of Sunny is acceptable. To get meaningful information you need to outlook(sunny).
etc.
Q1: It is not clear, why you want to assert/retract clauses, CapelliC's pointer to findall is most certainly what you need.
Q2: Restarting your prolog interpreter clears the facts you asserted. If you want to do this within a session, retractall/1 might come in handy (otherwise you need to retract each fact seperately).
Upvotes: 3