# \#difference-list

**URL:** https://swi-prolog.discourse.group/tag/difference-list/63.md

[Latest](https://swi-prolog.discourse.group/latest.md) · [Categories](https://swi-prolog.discourse.group/categories.md) · [Tags](https://swi-prolog.discourse.group/tags.md)

---

## [Using Xs\\Ys for difference list results in compile error](https://swi-prolog.discourse.group/t/using-xs-ys-for-difference-list-results-in-compile-error/8576)

<div class="topic-metadata">

**Author:** [@JS\_Nielsen](https://swi-prolog.discourse.group/u/JS_Nielsen)\
**Replies:** 3\
**Last updated:** [November 3, 2024, 7:52am UTC](https://swi-prolog.discourse.group/t/using-xs-ys-for-difference-list-results-in-compile-error/8576 "2024-11-03T07:52:50Z")

</div>

I am reading “the art of Prolog” by Sterling and Shapiro and is stuck on chapter 15.1 ‘Difference-lists’. In short the use of Xs\\Ys for a difference-list does not compile as expected. I tried compiling both from swipl an…

---

## [How to use difference lists to implement queues -vs- accumulators and recursion?](https://swi-prolog.discourse.group/t/how-to-use-difference-lists-to-implement-queues-vs-accumulators-and-recursion/5106)

<div class="topic-metadata">

**Author:** [@Hierophantos](https://swi-prolog.discourse.group/u/Hierophantos)\
**Replies:** 2\
**Last updated:** [March 8, 2022, 4:37pm UTC](https://swi-prolog.discourse.group/t/how-to-use-difference-lists-to-implement-queues-vs-accumulators-and-recursion/5106 "2022-03-08T16:37:56Z")

</div>

I’m trying to better grok difference lists. I’d like to use them for the below predicate. Currently it’s using recursion with an accumulator. This creates a stack, which reverses the order that’d I’d like them to be in. …

---

## [Debugging with difference list of character codes](https://swi-prolog.discourse.group/t/debugging-with-difference-list-of-character-codes/2689)

<div class="topic-metadata">

**Author:** [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Replies:** 0\
**Last updated:** [July 24, 2020, 8:25pm UTC](https://swi-prolog.discourse.group/t/debugging-with-difference-list-of-character-codes/2689 "2020-07-24T20:25:44Z")

</div>

Difference list of character codes are not friendly to writing for output because they are still a list of characters codes. An easy way to convert a difference list to a closed list is to unify the tail of the list wit…

---

## [Is there a has\_type/2 for difference list?](https://swi-prolog.discourse.group/t/is-there-a-has-type-2-for-difference-list/2622)

<div class="topic-metadata">

**Author:** [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Replies:** 9\
**Last updated:** [July 16, 2020, 12:25pm UTC](https://swi-prolog.discourse.group/t/is-there-a-has-type-2-for-difference-list/2622 "2020-07-16T12:25:51Z")

</div>

has\_type/2 is used with must\_be/2 and is\_of\_type/2. It can be used to identify closed list, e.g. is\_of\_type(list,L) and open list (partial list), e.g. :- multifile error:has\_type/2. error:has\_type(partial\_list,L0) :-…

---

## [Quick basic list questions. Not a test just checking what I believe to be correct](https://swi-prolog.discourse.group/t/quick-basic-list-questions-not-a-test-just-checking-what-i-believe-to-be-correct/2621)

<div class="topic-metadata">

**Author:** [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Replies:** 11\
**Last updated:** [July 11, 2020, 2:09pm UTC](https://swi-prolog.discourse.group/t/quick-basic-list-questions-not-a-test-just-checking-what-i-believe-to-be-correct/2621 "2020-07-11T14:09:17Z")

</div>

There are closed list which end with \[\] and open list which end with a variable, e.g. Closed list AKA list ?- write\_term(\[a,b,c\],\[dotlists(true)\]). .(a,.(b,.(c,\[\]))) true. Open list AKA Partial list ?- write\_term(\[a…
