I\'m working on a prolog algorithm that will perform a \"swap\" on a list.
Example:
Input: [1,2,3,4] -> Output: [3,4,1,2] Input: [1,2,3,4,5] -> Output: [4,5,3,1
round is not a function, it's a predicate. I haven't looked at the rest of the code, but that line should be
round
round(Length/2, R), trim(L, R, A)
EDIT: BTW, you're overthinking it.
swap([], []). swap([X], [X]). swap([X, Y | A], [Y, X | B]) :- swap(A, B).