I'm looking for these 2 algorithms...
REVERSE: given a list L, find the reverse R of L (top-level elements only). For example,
?-reverse([ ], R). should answer R = [ ]
?-reverse([1, 2, [3, 4]], R). should answer R = [[3, 4], 2, 1].
INTERSECT: given sets X and Y (represented as lists)...
I'm trying to come up with a selection sort algorithm for prolog. That is, lists X and Sorted satisfy the relation selection(X, Sorted) if Sorted is the sorted list containing all the elements of X.
For example, selection([3, 2, 2, 1, 4], Sorted) should return Sorted = [1, 2, 2, 3, 4].
Can...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.