Write the prolog predicates described in the assignments.
Try to use ``don't cares'' (instead of variable names) where appropriate. Don't use the builtin predicates.


Numerical comparison operators:
not equal  \=
smaller <
smaller or equal =<


Start time:
Mo 03 Jun 2019 16:00:00
End time:
Mo 17 Jun 2019 16:00:00

Assignments: 9

lastelem (1P)
lastelem(L,X) if L is a list then X should be the last element of L
contains (1P)
contains(L,X) is true if L is a list and L contains at minimum one element equal to X
backwards (1P)
backwards(L,R) if L is a list then R is a list with the same elements in reverse order
neighbors (1P)
neighbors(X,Y,L) is true if L is a list and X and Y are neighboring elements in L
replace (2P)
replace(L,X,Y,R) if L is a list then R is the same list with all occurrences of X replaced with Y
compress (2P)
compress(L1,L2) The list L2 is obtained from the list L1 by compressing repeated occurrences of elements into a single copy of the element. Example: ?- compress([1,1,2,2,2,3,3,4],L) should yield L...
pack (2P)
pack(L1,L2) The list L2 is obtained from the list L1 by packing repeated occurrences of elements into separate sublists. Example: ?- compress([1,1,2,2,2,3,3,4],L) should yield L =...
Natural Numbers (4P)
Assume that s is a functor that represents the successor of a number, i.e. s(0)=1, s(s(0))=2 etc. Now given the following predicates: natural_number(0). natural_number(s(X)) :- natural_number(X)....
Puzzle (16P)
The Problem: A farmer comes by a river with a cabbage, a wolf and a goat. He wants to safely cross the river. There is a boat that can only accommodate two things at a time and only the farmer can...