I need to do this homework assignment using prolog (SWI-flavor) and cant get my head around some things.
For example, if i want to iterate through a list and add it
you can use the if structure:
-> (do_something) ; (do_something else)
in this case:
goal(Stuff):-
do_something(X),
if_something(Y)-> do_this(Y) ; true,
always_do_this(Z).
or you simply write two clauses like:
goal(Stuff):-
do_something(X),
conditional_stuff(Y),
always_do_this(Z).
conditional_stuff(Y):-
condition(Y),
do_this(Y).
conditional_stuff(_).