[Previous] [Up]
Go backward to Prolog Samples
Go up to Difference Lists and Definite Clause Grammars


  1. When you use the difference list format, it is important to be careful with the choice of variable names. What would happen if you made the following query?
    | ?- List = [a,b,c|X], X = [d,e,f|X].
  2. We do not strictly use the difference list format to concatenate lists, but rather to identify parts of lists. You could use it to concatenate lists however. Here is a single fact which encodes difference list concatenation:
    (I have used A-B instead of A,B to make it easier to see which lists belong together.) Call it with a few different lists so that you understand how it works.
  3. To think about: Why is an explicit call to dl_conc not needed in the Prolog procedure?


[Previous] [Up]