on February 4th, 2007 at 07:41 am |
This reminds me of difference lists in prolog. (You pass a list with the last item being an unbound variable, and pass the variable too, resulting in a queue)
E.g. With append defined as: dappend(A-B,B-C,A-C).
| ?- dappend([1,2,3,4|X]-X,[5,6,7,8|Y]-Y,W-Z) .
W = [1,2,3,4,5,6,7,8|Y]
X = [5,6,7,8|Y]
Z = Y
yes
E.g. With append defined as: dappend(A-B,B-C,A-C).
| ?- dappend([1,2,3,4|X]-X,[5,6,7,8|Y]-Y,W-Z)
W = [1,2,3,4,5,6,7,8|Y]
X = [5,6,7,8|Y]
Z = Y
yes
(Read Comments)