Consider the following function definition:
nrev([], []).
nrev([H|T0], L) :-
nrev(T0, T),
append(T, [H], L).
some things to note:
a) We still have the base/inductive case split, but notice that no other (unrelated) lines of code appear in between them.
b) That variables to be matched start with Capital letters (I had problems when I tried lowercase variables).
c) Code, such as this, goes in the left pane of the Swish Window.
nrev([1,2,3],A).
This is a query--basically it asks: what would A have to be make this statement true.
It should be entered into the pane at the bottom right of the Swish window.
The correct response is A = [3,2,1] (click the "run" far bottom right to execute the query).
sumOdd(A,B,C,D) :-
D is A+C.
This is a valid function; but notice that the interpreter will complain about the variable "B", because it never gets used. The system would prefer:
sumOdd(A,_,C,D) :-
D is A+C.