I've been reading about how great difference lists are and I was hoping to test some examples from the books. But it seems that you can't pass lists as input in just the same way as, for instance append([1,2,3], [4,5], X), where X=[1,2,3,4,5]. Strangely, no book I've consulted ever mentions this.
I'm running the code on swipl and I'm interested in testing out a difference append predicate:
dapp(A-B,B-C,A-C).
and a "rotate first element of list" predicate:
drotate([H|T]-T1,R-S) :- dapp(T-T1,[H|L]-L,R-S).
Any ideas, how I can test these predicates in swipl?
Try:
dapp([1,2,3|X] - X,[4,5,6] - [],Y - []).
drotate([1,2,3|X] - X,Y - []).
Y is the answer for both predicates.