I've created a function in Prolog to "turn" a list, e.g. to append the head of a list to the tail like so:
?- turn([a,b,c,d,e], Tlist).
Tlist=[b,c,d,e,a]
Within the context of my program, I'd like to be able to use predefined lists for the rule, such as
alist([a,b,c,d,e,f])
but I get lots of different errors. I've tried the following as arguments:
turn(alist(L),R).
listv(X) :- alist(L), member(X, L).
turn(listv(X),R).
and I understand that each of these are different representations of the list according to Prolog, but I'm not sure which list representation is appropriate to complete the operation on a predefined list.
Thanks!
turn(listv(X), R)
. And what does that predicate/fact mean? It has two variables that aren't defined. You would need something like,turned_lists(P, Result) :- call(P, L), turn(L, Result).
and call it as,turned_lists(alist, Result).
or something like that, all depending upon what you're trying to achieve exactly (which isn't totally clear). – lurker