Working with lists in Prolog

6 important questions on Working with lists in Prolog

What is a list?

A list can be defined as a sequence of objects which are called the elements of the list.

What is the vertical bar operator used for?

To make a distinction between the head and the tail

What is the unification of the following atom: p([X, 3 | Z]) unifies p([b, Y, c, b])

X=b, Y=3, Z=[c,b]
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart

[ ] and [ ], [X|Y] and [a] with X=a Y=[ ], [a,b,c] and [a|[b,c]] are these examples of matching lists or non matching lists?

Matching lists

[a] and [ ], [a,b,c] and [X,b,X], [ ] and [ [ ] ], [X, Y] and [U,V,W] are these examples of matching or non matching lists?

Non matching lists

[john, joe, sue] unifies with [P | Z] for:

P= John and Z = [joe, sue]

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo